diff options
Diffstat (limited to '.local/bin')
-rwxr-xr-x | .local/bin/chwp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/.local/bin/chwp b/.local/bin/chwp index 32e4707..aead087 100755 --- a/.local/bin/chwp +++ b/.local/bin/chwp @@ -53,9 +53,20 @@ make_pape() output=$(mktemp) imagelist=$(mktemp) - for resolution in $(xrandr -q | grep -F ' connected ' | grep -Eo '\b[[:digit:]]+x[[:digit:]]+') + for resolution in $(xrandr -q | grep -F ' connected ' | grep -Eo '\b[[:digit:]]+x[[:digit:]]+') do - printf '"%s"\n' "$(get_pape "$resolution")" >> "$imagelist" + current_pape=$(get_pape "$resolution") + + if [ "$current_pape" = "" ] + then + printf "No wallpapers for %s\n" "$resolution" >&2 + + current_pape="$(mktemp --tmpdir XXXXX.png)" + convert -size "$resolution" canvas:gray "$current_pape" + fi + + printf '"%s"\n' "$current_pape" >> "$imagelist" + unset current_pape done eval convert +append $(cat $imagelist) "$output" @@ -67,6 +78,11 @@ make_pape() get_pape() { + if [ ! -d "$directory/$1" ] + then + return 1 + fi + printf "%s\n" "$(find "$directory/$1" -type f | shuf | head -n 1)" } |