aboutsummaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2020-02-12 17:37:26 +0100
committerPatrick Spek <p.spek@tyil.nl>2020-02-12 17:37:26 +0100
commit873b637390aa0e35d44fedc3e4fd43ed1ae7c15a (patch)
treedcafb0ef72233bbf17deecc9a578f9eae6e36f36 /.local
parenteab9aecce316200120549a1f17682a694d66a0c8 (diff)
Fallback for missing resolutions
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/chwp20
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)"
}