diff --git a/aly.nix b/aly.nix index cc523c0c..140c96f8 100644 --- a/aly.nix +++ b/aly.nix @@ -46,7 +46,7 @@ in { }; hyprland = { enable = true; - hyprpaper.randomWallpaper = true; + randomWallpaper = true; }; sway = { enable = true; diff --git a/dustin.nix b/dustin.nix index d4f40f3c..91a76732 100644 --- a/dustin.nix +++ b/dustin.nix @@ -27,7 +27,7 @@ defaultApps.enable = true; hyprland = { enable = true; - hyprpaper.randomWallpaper = false; + randomWallpaper = false; }; sway = { enable = true; diff --git a/homeManagerModules/desktop/hypr/default.nix b/homeManagerModules/desktop/hypr/default.nix index 06b9f92c..c918528c 100644 --- a/homeManagerModules/desktop/hypr/default.nix +++ b/homeManagerModules/desktop/hypr/default.nix @@ -6,7 +6,7 @@ inputs, ... }: { - imports = [./hypridle ./hyprlock ./hyprpaper ./hyprshade]; + imports = [./hypridle ./hyprlock ./hyprshade ./randomWallpaper.nix]; options = { alyraffauf.desktop.hyprland.enable = @@ -16,6 +16,11 @@ default = true; type = lib.types.bool; }; + alyraffauf.desktop.hyprland.randomWallpaper = lib.mkOption { + description = "Whether to enable random wallpaper script."; + default = true; + type = lib.types.bool; + }; }; config = lib.mkIf config.alyraffauf.desktop.hyprland.enable { @@ -25,10 +30,7 @@ hyprland = { hypridle.enable = lib.mkDefault false; hyprlock.enable = lib.mkDefault false; - hyprpaper = { - enable = lib.mkDefault true; - randomWallpaper = lib.mkDefault true; - }; + hyprshade.enable = lib.mkDefault true; }; theme.enable = lib.mkDefault true; @@ -99,7 +101,7 @@ bar = lib.getExe pkgs.waybar; launcher = lib.getExe pkgs.fuzzel; notifyd = lib.getExe pkgs.mako; - wallpaperd = lib.getExe pkgs.hyprpaper; + wallpaperd = "${lib.getExe pkgs.swaybg} -i ${config.alyraffauf.desktop.theme.wallpaper}"; logout = lib.getExe pkgs.wlogout; # lock = pkgs.hyprlock + "/bin/hyprlock --immediate"; # idled = pkgs.hypridle + "/bin/hypridle"; @@ -155,7 +157,7 @@ env = QT_QPA_PLATFORMTHEME,${qt_platform_theme} # Execute necessary apps - exec-once = ${wallpaperd} + exec-once = ${if config.alyraffauf.desktop.hyprland.randomWallpaper then "" else "${wallpaperd}"} exec-once = ${bar} exec-once = ${notifyd} exec-once = ${lib.getExe' pkgs.wl-clipboard "wl-paste"} --type image --watch ${lib.getExe pkgs.cliphist} store diff --git a/homeManagerModules/desktop/hypr/hyprpaper/default.nix b/homeManagerModules/desktop/hypr/hyprpaper/default.nix deleted file mode 100644 index 5c44090e..00000000 --- a/homeManagerModules/desktop/hypr/hyprpaper/default.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ - pkgs, - lib, - config, - inputs, - ... -}: { - imports = [./hyprpaper-random.nix]; - - options = { - alyraffauf.desktop.hyprland.hyprpaper.enable = - lib.mkEnableOption "Enables hyprpaper and assorted wallpapers."; - }; - - config = lib.mkIf config.alyraffauf.desktop.hyprland.hyprpaper.enable { - # Packages that should be installed to the user profile. - home.packages = with pkgs; [inputs.nixpkgsUnstable.legacyPackages."${pkgs.system}".hyprpaper]; - - xdg.configFile."hypr/hyprpaper.conf".text = '' - preload = ${config.alyraffauf.desktop.theme.wallpaper} - - wallpaper = ,${config.alyraffauf.desktop.theme.wallpaper} - - splash = false - ''; - }; -} diff --git a/homeManagerModules/desktop/hypr/hyprpaper/hyprpaper-random.nix b/homeManagerModules/desktop/hypr/hyprpaper/hyprpaper-random.nix deleted file mode 100644 index d94b33e7..00000000 --- a/homeManagerModules/desktop/hypr/hyprpaper/hyprpaper-random.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ - pkgs, - lib, - config, - ... -}: let - hyprpaper-random = pkgs.writeShellScriptBin "hyprpaper-random" '' - directory=${config.home.homeDirectory}/.local/share/backgrounds - - if [ -d "$directory" ]; then - while true; do - sleep 30 - ${config.wayland.windowManager.hyprland.package}/bin/hyprctl hyprpaper unload all - monitor=`${config.wayland.windowManager.hyprland.package}/bin/hyprctl monitors | grep Monitor | awk '{print $2}'` - for m in ''${monitor[@]}; do - random_background=$(ls $directory/*.{png,jpg} | shuf -n 1) - ${config.wayland.windowManager.hyprland.package}/bin/hyprctl hyprpaper preload $random_background - ${config.wayland.windowManager.hyprland.package}/bin/hyprctl hyprpaper wallpaper "$m,$random_background" - done - sleep 870 - done - fi - ''; -in { - options = { - alyraffauf.desktop.hyprland.hyprpaper.randomWallpaper = - lib.mkEnableOption "Enables hyprpaper random wallpaper script."; - }; - - config = lib.mkIf config.alyraffauf.desktop.hyprland.hyprpaper.randomWallpaper { - # Packages that should be installed to the user profile. - home.packages = with pkgs; [hyprpaper-random]; - - wayland.windowManager.hyprland.extraConfig = "exec-once = ${hyprpaper-random}/bin/hyprpaper-random"; - }; -} diff --git a/homeManagerModules/desktop/hypr/randomWallpaper.nix b/homeManagerModules/desktop/hypr/randomWallpaper.nix new file mode 100644 index 00000000..b04fb27a --- /dev/null +++ b/homeManagerModules/desktop/hypr/randomWallpaper.nix @@ -0,0 +1,41 @@ +{ + pkgs, + lib, + config, + ... +}: let + hyprbg-randomWallpaper = pkgs.writeShellScriptBin "hyprbg-randomWallpaper" '' + kill `pidof swaybg` + + OLD_PIDS=() + directory=${config.home.homeDirectory}/.local/share/backgrounds + + if [ -d "$directory" ]; then + while true; do + NEW_PIDS=() + monitor=`${config.wayland.windowManager.hyprland.package}/bin/hyprctl monitors | grep Monitor | awk '{print $2}'` + for m in ''${monitor[@]}; do + random_background=$(ls $directory/*.{png,jpg} | shuf -n 1) + ${lib.getExe pkgs.swaybg} -o $m -i $random_background & + NEW_PIDS+=($!) + done + + sleep 5 + + for pid in ''${OLD_PIDS[@]}; do + kill $pid + done + + OLD_PIDS=$NEW_PIDS + + sleep 895 + done + fi + ''; +in { + config = lib.mkIf config.alyraffauf.desktop.hyprland.randomWallpaper { + home.packages = with pkgs; [swaybg hyprbg-randomWallpaper]; + + wayland.windowManager.hyprland.extraConfig = "exec-once = ${lib.getExe hyprbg-randomWallpaper}"; + }; +} diff --git a/homeManagerModules/desktop/sway/default.nix b/homeManagerModules/desktop/sway/default.nix index 9c45ded2..894457d8 100644 --- a/homeManagerModules/desktop/sway/default.nix +++ b/homeManagerModules/desktop/sway/default.nix @@ -114,7 +114,7 @@ bar = lib.getExe pkgs.waybar; launcher = lib.getExe pkgs.fuzzel; notifyd = lib.getExe pkgs.mako; - wallpaperd = lib.getExe pkgs.swaybg; + wallpaperd = "${lib.getExe pkgs.swaybg} -i ${config.alyraffauf.desktop.theme.wallpaper}"; logout = lib.getExe pkgs.wlogout; lock = lib.getExe pkgs.swaylock; idled = @@ -356,7 +356,12 @@ }; startup = [ # {command = "${bar}";} - {command = "${wallpaperd}";} + { + command = + if config.alyraffauf.desktop.sway.randomWallpaper + then "" + else "${wallpaperd}"; + } {command = "${fileManager} --daemon";} {command = "${idled}";} {command = "${notifyd}";}