nix-config/modules/home-manager/desktop-river/swaybg.nix

27 lines
719 B
Nix

{ config, pkgs, ... }:
let
shell = "${pkgs.dash}/bin/dash";
wallpapers = "${config.home.homeDirectory}/Images/wallpapers/enabled";
find = "${pkgs.findutils}/bin/find";
shuf = "${pkgs.coreutils}/bin/shuf";
swaybg = "${pkgs.swaybg}/bin/swaybg";
setbg = pkgs.writeScriptBin "setbg" ''
#!/${shell}
BG="$(${find} "${wallpapers}" -type f | ${shuf} -n 1)"
${swaybg} --image $BG --mode fill
'';
in {
systemd.user.services.setbg = {
Unit = {
Description = "set background using swaybg";
BindsTo = [ "river-session.target" ];
};
Service = {
Type = "simple";
ExecStart = "${setbg}/bin/setbg";
};
Install = { WantedBy = [ "river-session.target" ]; };
};
}