2024-04-13 18:31:10 -04:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
swaybg-random = pkgs.writeShellScriptBin "swaybg-random" ''
|
2024-05-05 16:44:02 -04:00
|
|
|
kill `pidof swaybg`
|
|
|
|
|
|
|
|
OLD_PIDS=()
|
2024-04-13 18:31:10 -04:00
|
|
|
directory=${config.home.homeDirectory}/.local/share/backgrounds
|
|
|
|
|
|
|
|
if [ -d "$directory" ]; then
|
|
|
|
while true; do
|
2024-05-05 16:44:02 -04:00
|
|
|
NEW_PIDS=()
|
|
|
|
|
2024-04-13 18:31:10 -04:00
|
|
|
random_background=$(ls $directory/*.{png,jpg} | shuf -n 1)
|
2024-05-05 16:44:02 -04:00
|
|
|
${pkgs.swaybg}/bin/swaybg -i $random_background &
|
|
|
|
NEW_PIDS+=($!)
|
|
|
|
|
|
|
|
sleep 5
|
|
|
|
|
|
|
|
for pid in ''${OLD_PIDS[@]}; do
|
|
|
|
kill $pid
|
|
|
|
done
|
|
|
|
|
|
|
|
OLD_PIDS=$NEW_PIDS
|
|
|
|
|
|
|
|
sleep 895
|
2024-04-13 18:31:10 -04:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
in {
|
|
|
|
options = {
|
2024-04-21 13:47:41 -04:00
|
|
|
alyraffauf.desktop.river.randomWallpaper =
|
2024-04-13 18:31:10 -04:00
|
|
|
lib.mkEnableOption "Enables swaybg random wallpaper script.";
|
|
|
|
};
|
|
|
|
|
2024-04-21 13:47:41 -04:00
|
|
|
config = lib.mkIf config.alyraffauf.desktop.river.randomWallpaper {
|
2024-04-13 18:31:10 -04:00
|
|
|
# Packages that should be installed to the user profile.
|
|
|
|
home.packages = with pkgs; [swaybg swaybg-random];
|
|
|
|
|
2024-04-13 20:51:44 -04:00
|
|
|
wayland.windowManager.river.extraConfig = ''
|
|
|
|
kill `ps aux | grep swaybg-random | grep -v grep | awk '{print $2}'`
|
|
|
|
swaybg-random &
|
|
|
|
'';
|
2024-04-13 18:31:10 -04:00
|
|
|
};
|
|
|
|
}
|