aboutsummaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2020-03-30 19:04:50 +0200
committerPatrick Spek <p.spek@tyil.nl>2021-08-14 11:59:35 +0200
commit159b6d3ea0878df425015b31561b80b32fb25575 (patch)
tree185d0887b9b11cd48ec430605a74eaf18926ad70 /.local
parentcdcc1c394f9b0cb135a671f0b1cb6fe80638fbe3 (diff)
Update chwp to allow ignoring monitors
This allows me to filter out monitors that duplicate another screen.
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/chwp32
1 files changed, 24 insertions, 8 deletions
diff --git a/.local/bin/chwp b/.local/bin/chwp
index aead087..c25078a 100755
--- a/.local/bin/chwp
+++ b/.local/bin/chwp
@@ -12,7 +12,6 @@ main()
size=${CHWP_SIZE:-1920x1080}
timeout=${1:-0}
walldir=$directory/$size
- screencount=${CHWP_SCREENCOUNT:-$(xrandr -q | grep -F ' connected ' | wc -l)}
# Fail early if there's no wallpaper directory
if [ ! -d "$walldir" ]
@@ -21,7 +20,7 @@ main()
exit 1
fi
- CACHEFILE=$(mktemp)
+ CACHEFILE="$(mktemp)"
find "${walldir}" -type f > "$CACHEFILE"
@@ -29,7 +28,7 @@ main()
if [ "$timeout" -eq 0 ]
then
set_papes
- exit 0
+ exit
fi
# Otherwise, change it every so often
@@ -42,7 +41,7 @@ main()
set_papes()
{
- pape=$(make_pape)
+ pape="$(make_pape)"
feh --bg-fill "$pape"
rm -f -- "$pape"
@@ -50,11 +49,24 @@ set_papes()
make_pape()
{
- output=$(mktemp)
- imagelist=$(mktemp)
+ output="$(mktemp)"
+ imagelist="$(mktemp)"
+ monitorlist="$(mktemp)"
- for resolution in $(xrandr -q | grep -F ' connected ' | grep -Eo '\b[[:digit:]]+x[[:digit:]]+')
+ xrandr -q | grep -F ' connected ' > "$monitorlist"
+
+ while read -r monitor
do
+ if [ -f "$HOME/.local/etc/x/chwp-filter" ]
+ then
+ if printf "%s" "$monitor" | grep -qf "$HOME/.local/etc/x/chwp-filter"
+ then
+ printf "Filtering %s\n" "$monitor" >&2
+ continue
+ fi
+ fi
+
+ resolution="$(printf "%s" "$monitor" | grep -Eo '\b[[:digit:]]+x[[:digit:]]+')"
current_pape=$(get_pape "$resolution")
if [ "$current_pape" = "" ]
@@ -66,9 +78,13 @@ make_pape()
fi
printf '"%s"\n' "$current_pape" >> "$imagelist"
+
+ unset resolution
unset current_pape
- done
+ done < "$monitorlist"
+ # shellcheck disable=SC2046
+ # shellcheck disable=SC2086
eval convert +append $(cat $imagelist) "$output"
printf "%s" "$output"