bg_random (651B)
1 #!/usr/bin/env zsh 2 # Find for each monitor image relative to its resolutions. (wide/tall monitor) 3 4 bg_dir="$HOME/bg" 5 6 resolutions=($(\ 7 xrandr --listmonitors |\ 8 sed -n 's/.* \([[:digit:]]\+\)\/[[:digit:]]\+x\([[:digit:]]\+\)\/[[:digit:]]\+.*/\1x\2/p')) 9 10 get_img(){ 11 if [[ ${1} == 'wide' ]]; then 12 echo "$(fd ^wide $bg_dir | shuf | head -1)" 13 else 14 echo "$(fd ^tall $bg_dir | shuf | head -1)" 15 fi 16 } 17 18 typeset -a imgs 19 for res in "${resolutions[@]}"; do 20 echo $res | tr 'x' ' ' | read width height 21 if [[ (( $width > $height )) ]]; then 22 i=$(get_img 'wide') 23 else 24 i=$(get_img 'tall') 25 fi 26 imgs=($imgs $i) 27 done 28 29 feh --bg-fill $imgs