From 6416666e29e602b2757e4a94d3a61a4555c4808e Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Sat, 20 Apr 2024 10:06:28 -0400 Subject: [PATCH] sway: added default random wallpaper script --- homeManagerModules/desktop/sway/default.nix | 3 +- .../desktop/sway/randomWallpaper.nix | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 homeManagerModules/desktop/sway/randomWallpaper.nix diff --git a/homeManagerModules/desktop/sway/default.nix b/homeManagerModules/desktop/sway/default.nix index d93c6a10..6b098f57 100644 --- a/homeManagerModules/desktop/sway/default.nix +++ b/homeManagerModules/desktop/sway/default.nix @@ -4,6 +4,7 @@ config, ... }: { + imports = [./randomWallpaper.nix]; options = { alyraffauf.desktop.sway.enable = lib.mkEnableOption "Sway with extra apps."; }; @@ -19,6 +20,7 @@ firefox.enable = lib.mkDefault true; kanshi.enable = lib.mkDefault true; }; + desktop.sway.randomWallpaper.enable = lib.mkDefault true; }; # Packages that should be installed to the user profile. home.packages = with pkgs; [ @@ -135,7 +137,6 @@ size = 12.0; }; startup = [ - {command = "${wallpaperd}";} {command = "${pkgs.autotiling}/bin/autotiling";} {command = "${notifyd}";} {command = "${pkgs.wl-clipboard}/bin/wl-paste --type text --watch cliphist store";} diff --git a/homeManagerModules/desktop/sway/randomWallpaper.nix b/homeManagerModules/desktop/sway/randomWallpaper.nix new file mode 100644 index 00000000..e8f0ff31 --- /dev/null +++ b/homeManagerModules/desktop/sway/randomWallpaper.nix @@ -0,0 +1,33 @@ +{ + pkgs, + lib, + config, + ... +}: let + sway-randomWallpaper = pkgs.writeShellScriptBin "sway-randomWallpaper" '' + directory=${config.home.homeDirectory}/.local/share/backgrounds + + if [ -d "$directory" ]; then + while true; do + kill `pidof swaybg` + random_background=$(ls $directory/*.{png,jpg} | shuf -n 1) + ${pkgs.swaybg}/bin/swaybg -i $random_background & + sleep 300 + done + fi + ''; +in { + options = { + alyraffauf.desktop.sway.randomWallpaper.enable = + lib.mkEnableOption "Enable Sway random wallpaper script."; + }; + + config = lib.mkIf config.alyraffauf.desktop.sway.randomWallpaper.enable { + # Packages that should be installed to the user profile. + home.packages = with pkgs; [swaybg sway-randomWallpaper]; + + wayland.windowManager.sway.config.startup = [ + {command = "${sway-randomWallpaper}/bin/sway-randomWallpaper";} + ]; + }; +}