[download]

local/bin/wallpapers

   1 #!/bin/bash
   2 
   3 i=($(du -b ~/.theme/background))
   4 d=(~/Обои/ ~/Wallpapers/ ~/Pictures/Wallpapers/ /usr/share/backgrounds/)
   5 
   6 list(){ # {{{
   7     find "${d[@]}" -type f -exec du -b {} + 2>&- |
   8     sort -k 2 | awk -F \\t -v i=$i "$1"
   9 } # }}}
  10 
  11 [[ $1 == -c || $1 == --curr* ]] && list '$1 == i { print $2 }'
  12 [[ $1 == -p || $1 == --prev* ]] && list '$1 == i { print p; exit } { p = $2 }'   | xargs -r theme -b
  13 [[ $1 == -n || $1 == --next* ]] && list 'n { print $2; exit } $1 == i { n = 1 }' | xargs -r theme -b
  14 [[ $1 == -r || $1 == --rand* ]] && list '{ print $2 }' | shuf -n 1               | xargs -r theme -b
  15 
  16 [[ $1 ]] && exit
  17 
  18 n=$(list '$1 == i { print NR }')
  19 sxiv -rton ${n:-1} "${d[@]}" | xargs -r theme -b