2024-04-20 10:06:28 -04:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
sway-randomWallpaper = pkgs.writeShellScriptBin "sway-randomWallpaper" ''
|
2024-04-26 13:49:44 -04:00
|
|
|
kill `pidof swaybg`
|
|
|
|
|
|
|
|
OLD_PIDS=()
|
2024-04-20 10:06:28 -04:00
|
|
|
directory=${config.home.homeDirectory}/.local/share/backgrounds
|
|
|
|
|
|
|
|
if [ -d "$directory" ]; then
|
|
|
|
while true; do
|
2024-04-27 22:34:21 -04:00
|
|
|
NEW_PIDS=()
|
2024-04-26 13:49:44 -04:00
|
|
|
|
2024-04-26 13:17:22 -04:00
|
|
|
monitor=`${config.wayland.windowManager.sway.package}/bin/swaymsg -t get_outputs -p | grep Output | awk '{print $2}'`
|
|
|
|
for m in ''${monitor[@]}; do
|
|
|
|
random_background=$(ls $directory/*.{png,jpg} | shuf -n 1)
|
|
|
|
${pkgs.swaybg}/bin/swaybg -o $m -i $random_background &
|
2024-04-27 22:34:21 -04:00
|
|
|
NEW_PIDS+=($!)
|
|
|
|
done
|
|
|
|
|
|
|
|
sleep 5
|
|
|
|
|
|
|
|
for pid in ''${OLD_PIDS[@]}; do
|
|
|
|
kill $pid
|
2024-04-26 13:17:22 -04:00
|
|
|
done
|
2024-04-26 13:49:44 -04:00
|
|
|
|
2024-04-27 22:34:21 -04:00
|
|
|
OLD_PIDS=$NEW_PIDS
|
|
|
|
|
|
|
|
sleep 895
|
2024-04-20 10:06:28 -04:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
in {
|
|
|
|
options = {
|
2024-04-20 15:27:27 -04:00
|
|
|
alyraffauf.desktop.sway.randomWallpaper =
|
2024-04-20 10:06:28 -04:00
|
|
|
lib.mkEnableOption "Enable Sway random wallpaper script.";
|
|
|
|
};
|
|
|
|
|
2024-04-20 15:27:27 -04:00
|
|
|
config = lib.mkIf config.alyraffauf.desktop.sway.randomWallpaper {
|
2024-04-20 10:06:28 -04:00
|
|
|
# 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";}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|