wallpaper 837 B

1234567891011121314151617181920212223242526
  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. wallpaper_cmd="feh --no-fehbg"
  15. monitor_count=$(xrandr -d :0 -q | grep -c " connected")
  16. while [ $monitor_count -gt 0 ]; do
  17. wallpaper_cmd="$wallpaper_cmd --bg-max \"$(find $wallpaper_path -type f | sort -R | tail -1)\""
  18. let monitor_count=monitor_count-1
  19. done
  20. eval "$wallpaper_cmd"
  21. sleep $wallpaper_sleep_for
  22. done