diff options
author | Basti <mail@sebastian-sellmeier.de> | 2021-05-29 18:48:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-29 18:48:38 +0200 |
commit | 1c36673ecbc85bd0be8dc88249568aa8ce7f6795 (patch) | |
tree | aab9afa5e6d46ec5f19292fc3dbcea3397da1b4e | |
parent | bbe277c0db5cd11069770a8d95705bf85b288684 (diff) |
Should fix #218 and #175 (#227)
-rwxr-xr-x | betterlockscreen | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/betterlockscreen b/betterlockscreen index 57bfc3b..9c21ec7 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -81,6 +81,9 @@ prelock() { if [ -n "$(pidof dunst)" ]; then pkill -u "$USER" -USR1 dunst fi + if [[ "$runsuspend" = "true" ]]; then + lockargs="$lockargs -n" + fi } @@ -124,10 +127,9 @@ rec_get_random() { user_input="$dir" return fi - dirs=("$dir"*) + dirs=("$dir"/*) random_dir="${dirs[RANDOM % ${#dirs[@]}]}" rec_get_random "$random_dir" - exit 1 } @@ -168,7 +170,7 @@ logical_px() { # get dpi value from xrdb local DPI DPI=$(grep -oP 'Xft.dpi:\s*\K\d+' ~/.Xresources | bc) - if [ -n "$DPI" ]; then + if [ -z "$DPI" ]; then DPI=$(xdpyinfo | sed -En "s/\s*resolution:\s*([0-9]*)x([0-9]*)\s.*/\\$2/p" | head -n1) fi @@ -198,7 +200,9 @@ update() { rectangles=" " SR=$(xrandr --query | grep ' connected' | grep -o '[0-9][0-9]*x[0-9][0-9]*[^ ]*') for RES in $SR; do - SRA=("${RES//[x+]/ }") + # shellcheck disable=SC2206 + SRA=(${RES//[x+]/ }) + CX=$((SRA[2] + $(logical_px 25 1))) CY=$((SRA[1] - $(logical_px 30 2))) rectangles+="rectangle $CX,$CY $((CX+$(logical_px 300 1))),$((CY-$(logical_px 80 2))) " @@ -438,7 +442,7 @@ for arg in "$@"; do -l | --lock) runlock=true - [[ $runsuspend ]] || lockargs="$lockargs -n" + if [[ ${2:0:1} = '-' ]]; then shift 1 else |