2024-05-15 01:28:13 +02:00
|
|
|
{ pkgs, username, ... }:
|
|
|
|
|
|
|
|
pkgs.writeShellScriptBin "wallsetter" ''
|
|
|
|
WALLPAPER=$(find /home/${username}/Pictures/Wallpapers -name '*' | awk '!/.git/' | tail -n +2 | shuf -n 1)
|
|
|
|
PREVIOUS=$WALLPAPER
|
2024-05-17 23:03:33 +02:00
|
|
|
if [ "$WALLPAPER" == "$PREVIOUS" ]; then
|
|
|
|
WALLPAPER=$(find /home/${username}/Pictures/Wallpapers -name '*' | awk '!/.git/' | tail -n +2 | shuf -n 1)
|
|
|
|
fi
|
2024-05-15 01:28:13 +02:00
|
|
|
if [ -d /home/${username}/Pictures/Wallpapers ]; then
|
|
|
|
num_files=$(ls -1 /home/${username}/Pictures/Wallpapers | wc -l)
|
|
|
|
|
|
|
|
if [ $num_files -lt 1 ]; then
|
|
|
|
notify-send -t 9000 "The wallpaper folder is expected to have more than 1 image. Exiting Wallsetter."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
${pkgs.swww}/bin/swww img "$WALLPAPER" --transition-type random
|
|
|
|
fi
|
|
|
|
''
|