sway: added default random wallpaper script

This commit is contained in:
Aly Raffauf 2024-04-20 10:06:28 -04:00
parent 5e0b3a3d0e
commit 6416666e29
2 changed files with 35 additions and 1 deletions

View file

@ -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";}

View file

@ -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";}
];
};
}