3 ### XXX Chose not to 'set -e' because arithmetic evaluation can cause a non-zero exit.
4 ### XXX Chose not to 'set -u' because unset params ($1, $2, ...) cause failures.
5 ### Solutions to the above are ugly.
15 q | Q
) echo 'CMD_QUIT';;
16 h | H
) echo 'CMD_MOVE_BACK';;
17 l | L
) echo 'CMD_MOVE_FORWARD';;
18 f | F
) echo 'CMD_FAVORITE_ADD';;
19 r | R
) echo 'CMD_FAVORITE_REMOVE';;
20 s | S
) echo 'CMD_SET_CURRENT';;
21 *) echo 'CMD_UKNOWN';;
30 if file "$path" |
grep 'image data' > /dev
/null
33 # \r jumps to the beginning of the line:
34 printf '\rFound %d images.' "$n" >&2
35 paths
["$(( n - 1 ))"]="$path"
41 paths_set_from_dir_find
() {
42 paths_set
< <(find "$1" -type f
)
45 paths_set_from_favs
() {
46 paths_set
< <(sort -k 2 "$FILE_WALLPAPER_FAVS" |
awk '{sub("^" $1 " +", ""); print}')
53 printf '%d of %d %s\n' "$(( i + 1 ))" "$n" "$path"
54 feh
--bg-scale "$path"
59 local path
="${paths[$i]}"
61 set_wallpaper
"$i" "$path"
65 if [[ "${paths[$i]}" != "$path" ]]
68 set_wallpaper
"$i" "$path"
71 case "$(read_command)" in
75 (( i
= i
== 0 ?
(n
- 1) : i
- 1));;
77 (( i
= (i
+ 1) % n
));;
79 printf 'Adding to favorites set: "%s"\n' "$path" >&2
82 printf 'Removing from favorites set: "%s"\n' "$path" >&2
83 digest
=$
(sha256sum
"$path" |
awk '{print $1}')
84 grep -v "$digest" "$FILE_WALLPAPER_FAVS" \
86 | sponge
"$FILE_WALLPAPER_FAVS"
89 printf 'Setting as current: "%s"\n' "$path" >&2
90 echo "$path" > "$FILE_WALLPAPER_CURR";;
99 f | fav
) paths_set_from_favs
;;
100 d | dir
) paths_set_from_dir_find
"$2";;
101 a | all
) paths_set_from_dir_find
"$DIR_WALLPAPERS";;
103 paths_set_from_dir_find
"$DIR_WALLPAPERS";;
105 printf 'Error: unknown source "%s"\n' "$1" >&2
This page took 0.098747 seconds and 4 git commands to generate.