a821bf3766a1b02534ce79448a335b19b3ee2855
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.
19 if [[ "$buf" =~ ^
[0-9]+$
]]; then
20 if [[ "$buf" -gt 0 && "$buf" -le "$n" ]]; then
25 printf 'Error: out of range: %s\n' "$buf" >&2
29 printf 'Error: not an integer: %s\n' "$buf" >&2
39 q | Q
) _command
='CMD_QUIT';;
40 h | H
) _command
='CMD_MOVE_BACK';;
41 l | L
) _command
='CMD_MOVE_FORWARD';;
42 f | F
) _command
='CMD_FAVORITE_ADD';;
43 r | R
) _command
='CMD_FAVORITE_REMOVE';;
44 s | S
) _command
='CMD_SET_CURRENT';;
45 :) read_command_goto
;;
47 printf 'Error: unknown command: %s\n' "$char" >&2
48 _command
='CMD_UKNOWN';;
57 if file "$path" |
grep 'image data' > /dev
/null
60 # \r jumps to the beginning of the line:
61 printf '\rFound %d images.' "$n" >&2
62 paths
["$(( n - 1 ))"]="$path"
68 paths_set_from_dir_find
() {
69 paths_set
< <(find "$1" -type f
)
72 paths_set_from_favs
() {
73 paths_set
< <(sort -k 2 "$FILE_WALLPAPER_FAVS" |
awk '{sub("^" $1 " +", ""); print}')
80 printf '%d of %d %s\n' "$(( i + 1 ))" "$n" "$path"
81 feh
--bg-scale "$path"
86 local path
="${paths[$i]}"
88 set_wallpaper
"$i" "$path"
92 if [[ "${paths[$i]}" != "$path" ]]
95 set_wallpaper
"$i" "$path"
101 feh
--bg-scale "$(< "$FILE_WALLPAPER_CURR")"
106 (( i
= i
== 0 ?
(n
- 1) : i
- 1));;
108 (( i
= (i
+ 1) % n
));;
110 printf 'Adding to favorites set: "%s"\n' "$path" >&2
113 printf 'Removing from favorites set: "%s"\n' "$path" >&2
114 digest
=$
(sha256sum
"$path" |
awk '{print $1}')
115 grep -v "$digest" "$FILE_WALLPAPER_FAVS" \
117 | sponge
"$FILE_WALLPAPER_FAVS"
120 printf 'Setting as current: "%s"\n' "$path" >&2
121 echo "$path" > "$FILE_WALLPAPER_CURR";;
130 f | fav
) paths_set_from_favs
;;
131 d | dir
) paths_set_from_dir_find
"$2";;
132 a | all
) paths_set_from_dir_find
"$DIR_WALLPAPERS";;
134 paths_set_from_dir_find
"$DIR_WALLPAPERS";;
136 printf 'Error: unknown source "%s"\n' "$1" >&2
This page took 0.085033 seconds and 3 git commands to generate.