From 773bf1899abc70b602a7eb8532b5544bac2bfd38 Mon Sep 17 00:00:00 2001 From: Konstantin Koslowski Date: Fri, 6 May 2022 11:22:58 +0200 Subject: [PATCH] sway/bin: don't run multiple instances of swaylock --- bin/sway_helpers | 9 +++++++++ bin/sway_lock | 1 + 2 files changed, 10 insertions(+) diff --git a/bin/sway_helpers b/bin/sway_helpers index 353b44c..1b4b2ab 100644 --- a/bin/sway_helpers +++ b/bin/sway_helpers @@ -22,6 +22,15 @@ function _check_inhibit() { fi } +function _check_running() { + pgrep $1 + ret=$? + if [ $ret -eq 0 ]; then + _log _check_running: INFO already running $1 + exit 1 + fi +} + function _set_inhibit() { file=$1 action=$2 diff --git a/bin/sway_lock b/bin/sway_lock index 6df9701..f0c8976 100755 --- a/bin/sway_lock +++ b/bin/sway_lock @@ -16,6 +16,7 @@ function _clean() { function _lock() { _check_inhibit $INHIBIT_FILE $MEDIA_APP stop + _check_running $LOCK_APP $LOCK_APP $LOCK_ARGS }