From 1093ce51e69dcefb2da8f2cbca02f0f8fa11ad40 Mon Sep 17 00:00:00 2001 From: Timo Beckers Date: Fri, 14 Jan 2022 14:43:32 +0100 Subject: [PATCH] Run prelock and postlock synchronously to avoid race condition As reported in issue #285, running postlock in a subshell and immediately returning from lockselect() has a high chance of hitting `exit 0` before xset and dunstctl get a chance to execute. Run both prelock and postlock synchronously within lockselect(). --- betterlockscreen | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/betterlockscreen b/betterlockscreen index ffa9dfe..40d9589 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -278,7 +278,7 @@ postlock() { lockselect() { echof act "Running prelock..." - prelock & + prelock case "$1" in dim) if [ -f "$CUR_L_DIM" ]; then lock "$CUR_L_DIM"; else failsafe; fi ;; @@ -291,7 +291,7 @@ lockselect() { esac echof act "Running postlock..." - postlock & + postlock } # calculate adjustments for hidpi displays