zaneyos/scripts/wallsetter.nix
2024-05-17 16:03:33 -05:00

20 lines
722 B
Nix

{ pkgs, username, ... }:
pkgs.writeShellScriptBin "wallsetter" ''
WALLPAPER=$(find /home/${username}/Pictures/Wallpapers -name '*' | awk '!/.git/' | tail -n +2 | shuf -n 1)
PREVIOUS=$WALLPAPER
if [ "$WALLPAPER" == "$PREVIOUS" ]; then
WALLPAPER=$(find /home/${username}/Pictures/Wallpapers -name '*' | awk '!/.git/' | tail -n +2 | shuf -n 1)
fi
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
''