setbg 1.1 KB

12345678910111213141516171819202122232425
  1. #!/bin/dash
  2. set -e
  3. PATH=/bin:/usr/bin
  4. displays=$(xrandr | awk -F'[ +]' '/ connected/ {gsub("primary ", "", $0); print $1" "$3 }')
  5. walf="$HOME/.config/wallpaper"
  6. #true && {
  7. #echo updating weather...
  8. curl -s "http://www.meteo.pl/um/metco/mgram_pict.php?ntype=0u&row=399&col=186&lang=pl" > /tmp/wttr.png &&
  9. mogrify -alpha set -background none -channel A -evaluate multiply 0.3 +channel -negate /tmp/wttr.png &&
  10. # curl -s http://wttr.in/new%20york_ntQ.png > /tmp/wttr.png
  11. #} || [ ! -f /tmp/wttr.png ] && convert -size 1x1 xc:transparent /tmp/wttr.png
  12. true > $walf
  13. echo "$displays" | while read i; do
  14. screen_name="$(echo $i | cut -d' ' -f1)"
  15. screen_res="$(echo $i | cut -d' ' -f2)"
  16. [ -f "$1" ] && wal="$1" || { [ -d "$1" ] && wal="$1/$(ls "$1"|shuf -n1)"; } || exit
  17. convert "$wal" -resize $screen_res^ -gravity center -extent $screen_res "/tmp/$screen_name-wall.png"
  18. wal="$HOME/.cache/$screen_name-wall.png"
  19. convert "/tmp/$screen_name-wall.png" /tmp/wttr.png -geometry +80+80 -composite "$wal"
  20. c=" --output $screen_name --zoom $wal"
  21. printf "%s" "$c" >> "$walf"
  22. done
  23. opts="$(cat $walf)"
  24. xwallpaper $opts