From 873b637390aa0e35d44fedc3e4fd43ed1ae7c15a Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Wed, 12 Feb 2020 17:37:26 +0100 Subject: Fallback for missing resolutions --- .local/bin/chwp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to '.local') 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)" } -- cgit v1.1