diff --git a/instances/odin/hm.nix b/instances/odin/hm.nix index 6bbf0d9..d302099 100644 --- a/instances/odin/hm.nix +++ b/instances/odin/hm.nix @@ -147,6 +147,7 @@ ../../modules/hm/update_background.nix ../../modules/hm/vim.nix ../../modules/hm/webapp.nix + ../../modules/hm/wl_update_background.nix ../../modules/hm/xidlehook.nix ../../modules/hm/xresources.nix ../../modules/hm/zathura.nix diff --git a/instances/thor/hm.nix b/instances/thor/hm.nix index dd99868..7992a10 100644 --- a/instances/thor/hm.nix +++ b/instances/thor/hm.nix @@ -138,6 +138,7 @@ ../../modules/hm/update_background.nix ../../modules/hm/vim.nix ../../modules/hm/webapp.nix + ../../modules/hm/wl_update_background.nix ../../modules/hm/xidlehook.nix ../../modules/hm/xresources.nix ../../modules/hm/zathura.nix diff --git a/modules/hm/hyprland.nix b/modules/hm/hyprland.nix index 55c0e32..198660f 100644 --- a/modules/hm/hyprland.nix +++ b/modules/hm/hyprland.nix @@ -55,7 +55,7 @@ # See https://wiki.hyprland.org/Configuring/Keywords/ for more # Execute your favorite apps at launch - exec-once = waybar & swww init & blueman-applet & nm-applet # & firefox + exec-once = waybar & swww init & blueman-applet & nm-applet & systemctl --user restart swayidle # & firefox # Source a file (multi-file configs) # source = ~/.config/hypr/myColors.conf diff --git a/modules/hm/wl_update_background.nix b/modules/hm/wl_update_background.nix new file mode 100644 index 0000000..8ea4d79 --- /dev/null +++ b/modules/hm/wl_update_background.nix @@ -0,0 +1,40 @@ +{ pkgs, ... }: +let + update_time = "10m"; + backgrounds_directory = "$HOME/Immagini/Sfondi/1080+/1440+"; + update_script = pkgs.writeShellScriptBin "wl-update-background" '' + set -e + if [ $# -eq 0 ]; then + image=`${pkgs.findutils}/bin/find ${backgrounds_directory} -type f | ${pkgs.gnugrep}/bin/grep -v "/\." | ${pkgs.coreutils}/bin/shuf -n 1` + else + image="$1" + fi + echo "image: $image" + ${pkgs.swww}/bin/swww img "$image" + ''; +in +{ + home.packages = [ update_script ]; + + systemd.user.services."wl-update-background" = { + Unit = { + Description = "Set random desktop background using swww"; + After = [ "graphical-session.pre.target" ]; + PartOf = [ "graphical-session.target" ]; + RequiresMountsFor = [ "/home/bertof/Immagini" ]; + }; + Install = { WantedBy = [ "graphical-session.target" ]; }; + Service = { + Type = "oneshot"; + IOSchedulingClass = "idle"; + ExecStart = "${update_script}/bin/wl-update-background"; + }; + }; + + systemd.user.timers."wl-update-background" = { + Unit = { Description = "Set random desktop background using swww"; }; + Timer = { OnUnitActiveSec = update_time; }; + Install = { WantedBy = [ "timers.target" ]; }; + }; +} +