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

27 lines
719 B
Nix
Raw Normal View History

2023-02-06 16:38:52 +01:00
{ 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" ]; };
};
}