123456789101112131415161718192021222324 |
- #!/bin/bash
- # set sane defaults
- [ -z "$wallpaper_sleep_for" ] && wallpaper_sleep_for="180"
- [ -z "$wallpaper_path" ] && wallpaper_path="$(xdg-user-dir PICTURES)/wallpaper"
- mkdir -p "$wallpaper_path"
- # validate wallpaper path
- [ $(find "$wallpaper_path" -type f | wc -l) -gt 0 ] || exit 1
- # there can be only one
- while [ $(ps aux | grep -v 'grep' | grep -c "$0") -gt 2 ]; do
- kill $(ps aux | grep -v 'grep' | grep -v $$ | grep "$0" | awk '{print $2}') &> /dev/null
- done
- # infinitely change wallpaper
- while true; do
- sway_outputs=( $(swaymsg -t get_outputs | jq -r '.[].name') )
- for op in "${sway_outputs[@]}"; do
- wp="$(find $wallpaper_path -type f | sort -R | tail -1)"
- swaymsg "output $op bg $wp" fit \#001E27
- done
- sleep $wallpaper_sleep_for
- done
|