nixos/pkgs/wallpaper-changer/wallpaper-changer.sh

27 lines
759 B
Bash
Raw Normal View History

2024-05-11 13:49:12 +01:00
set +o errexit
set +o nounset
set +o pipefail
script_name=${BASH_SOURCE[0]}
2024-05-08 00:45:54 +01:00
for pid in $(pidof -x "$script_name"); do
if [ "$pid" != $$ ]; then
kill -15 "$pid"
fi
done
[ "$XDG_SESSION_TYPE" != "wayland" ] && echo "Not a Wayland session, exiting." && exit 1
wallpaper_dir="$HOME/.local/share/bg/"
2024-05-11 13:49:12 +01:00
swww_daemon_pid=$(pidof -x 'swww-daemon')
swww_pid=$(pidof -x 'swww')
[ -z "$swww_daemon_pid" ] || kill -15 "$swww_daemon_pid"
[ -z "$swww_pid" ] || kill -15 "$swww_pid"
swww-daemon &
2024-05-08 00:45:54 +01:00
while true; do
find "$wallpaper_dir" -type f -follow \( -iname \*.jpg -o -iname \*.png -o -iname \*.gif -o -iname \*.bmp \) | shuf | while read -r file; do
2024-05-11 13:49:12 +01:00
swww img "$file" --transition-step 10 --transition-fps 60
2024-05-08 00:45:54 +01:00
sleep 600
done
done