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 *) echo 'CMD_UKNOWN';;
29 if file "$path" |
grep 'image data' > /dev
/null
32 # \r jumps to the beginning of the line:
33 printf '\rFound %d images.' "$n" >&2
34 paths
["$(( n - 1 ))"]="$path"
40 paths_set_from_dir_find
() {
41 paths_set
< <(find "$1" -type f
)
44 paths_set_from_favs
() {
45 paths_set
< <(sort -k 2 "$FILE_WALLPAPER_FAVS" |
awk '{sub("^" $1 " +", ""); print}')
52 printf '%d of %d %s\n' "$(( i + 1 ))" "$n" "$path"
53 feh
--bg-scale "$path"
58 local path
="${paths[$i]}"
60 set_wallpaper
"$i" "$path"
64 if [[ "${paths[$i]}" != "$path" ]]
67 set_wallpaper
"$i" "$path"
70 case "$(read_command)" in
74 (( i
= i
== 0 ?
(n
- 1) : i
- 1));;
76 (( i
= (i
+ 1) % n
));;
78 printf 'Adding to favorites set: "%s"\n' "$path" >&2
81 printf 'Removing from favorites set: "%s"\n' "$path" >&2
82 digest
=$
(sha256sum
"$path" |
awk '{print $1}')
83 grep -v "$digest" "$FILE_WALLPAPER_FAVS" \
85 | sponge
"$FILE_WALLPAPER_FAVS"
95 f | fav
) paths_set_from_favs
;;
96 d | dir
) paths_set_from_dir_find
"$2";;
97 a | all
) paths_set_from_dir_find
"$DIR_WALLPAPERS";;
99 paths_set_from_dir_find
"$DIR_WALLPAPERS";;
101 printf 'Error: unknown source "%s"\n' "$1" >&2
This page took 0.104395 seconds and 4 git commands to generate.