wallpaper 756 B

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