set_wallpaper.sh 583 B

123456789101112131415161718192021
  1. #!/bin/bash
  2. ## This is my (demuredemeanor) nitrogen script for handling 1 vs multi monitors
  3. ##
  4. ## The script assumes nitrogen has been configured with at least one wallpaper
  5. ## dir already, as well as a default wallpaper.
  6. count=$(xrandr --query | awk 'BEGIN {c=-1} / connected/ {c+=1} END {print c}')
  7. ## a zero means just one monitor, so set the saved wallpaper
  8. ## Otherwise roll the dice for multiple monitors
  9. if [ $count -eq 0 ]; then
  10. nitrogen --restore
  11. else
  12. i=0
  13. until [ $i -gt $count ]; do
  14. nitrogen --random --set-auto --head=$i
  15. ((i++))
  16. done
  17. fi