From 3f26b4d1388ec8fd88e691113e0eee757c853be9 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sat, 6 Nov 2021 01:05:20 -0700 Subject: [PATCH] =?UTF-8?q?[herbstluftwm]=20Update=20=E2=80=98random-wallp?= =?UTF-8?q?aper=E2=80=99=20to=20use=20screen=20size?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of assuming that the screen is 3840x1080, check the size of the ‘root’ window. --- herbstluftwm/.config/herbstluftwm/autostart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/herbstluftwm/.config/herbstluftwm/autostart b/herbstluftwm/.config/herbstluftwm/autostart index bf011cd..d3709a1 100755 --- a/herbstluftwm/.config/herbstluftwm/autostart +++ b/herbstluftwm/.config/herbstluftwm/autostart @@ -11,8 +11,12 @@ function hc() { herbstclient "$@"; } # This function picks a random wallpaper from a list collection. function random-wallpaper() { - find ~/pictures/wallpapers -type f \ - -wholename '*/3840x1080/*' -o -wholename '*/patterns/*' \ + local rootinfo=$(xwininfo -root) + local width=$(echo $rootinfo | grep 'Width:' | sed 's/.*Width: \([[:digit:]]\+\).*/\1/') + local height=$(echo $rootinfo | grep 'Height:' | sed 's/.*Height: \([[:digit:]]\+\).*/\1/') + + find ~/pictures/wallpaper -type f \ + -wholename "*/${width}x${height}/*" -o -wholename '*/patterns/*' \ | shuf -n 1 }