From 3524441ba8671c05edd7749def284d698b624ad6 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Sun, 2 Feb 2020 03:46:36 +0100 Subject: [PATCH] Make lockscreen.sh screenres grab wm agnostic, add comments --- .scripts/wm/lock.sh | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/.scripts/wm/lock.sh b/.scripts/wm/lock.sh index 3e2d6d5..ce4f82b 100755 --- a/.scripts/wm/lock.sh +++ b/.scripts/wm/lock.sh @@ -1,26 +1,30 @@ #!/bin/sh -ICON="$XDG_CACHE_HOME/lock.png" +LOCK="$XDG_CACHE_HOME/lock.png" -if [ ! -f "$ICON" ]; then - touch "$ICON" +# Cache the lock image +if [ ! -f "$LOCK" ]; then + touch "$LOCK" - # Get the resolution of the first active monitor - RES="$(i3-msg -t get_outputs | \ - jq '.[] | select(.active==true) | .rect | .width, .height' | \ - head -n 2 | head -c -1 | tr '\n' 'x')" + # Get the resolution of the primary monitor + RES="$(xrandr -q | grep ' connected primary' \ + | grep -Eo '[0-9]{3,4}x[0-9]{3,4}' | head -c -1)" - convert "$(dirname "$0")/lock.png" -background none -gravity center -extent "$RES" "$ICON" + # Generate lock image + convert "$(dirname "$0")/lock.png" -background none -gravity center -extent "$RES" "$LOCK" fi +# Disable screensaver revert() { - xset dpms 0 0 0 + xset s off + xset -dpms } +# Set screensaver to 30 seconds trap revert HUP INT TERM xset +dpms dpms 30 30 30 -i3lock -n -i "$ICON" -B 6 -S 1 -e \ +i3lock -n -i "$LOCK" -B 6 -S 1 -e \ --radius=47 \ --ring-width=5.0 \ --verifcolor=00000000 \