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().
This commit is contained in:
Timo Beckers 2022-01-14 14:43:32 +01:00
parent c625f8b8a1
commit 1093ce51e6
No known key found for this signature in database
GPG key ID: 4130D6AE4B962121

View file

@ -278,7 +278,7 @@ postlock() {
lockselect() { lockselect() {
echof act "Running prelock..." echof act "Running prelock..."
prelock & prelock
case "$1" in case "$1" in
dim) if [ -f "$CUR_L_DIM" ]; then lock "$CUR_L_DIM"; else failsafe; fi ;; dim) if [ -f "$CUR_L_DIM" ]; then lock "$CUR_L_DIM"; else failsafe; fi ;;
@ -291,7 +291,7 @@ lockselect() {
esac esac
echof act "Running postlock..." echof act "Running postlock..."
postlock & postlock
} }
# calculate adjustments for hidpi displays # calculate adjustments for hidpi displays