From 321b8e8c5fbf494e559be014ca02a55df106dea3 Mon Sep 17 00:00:00 2001 From: Sourav Das Date: Mon, 7 Jun 2021 03:43:44 +0530 Subject: [PATCH] Don't change state of dunst on unlock if paused on lock (#233) * Fix: Don't change state of dunst on unlock if paused on lock (credits to @souravdas142) --- betterlockscreen | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/betterlockscreen b/betterlockscreen index c9152ad..84974b3 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -40,6 +40,9 @@ init_config () { wallpaper_cmd="feh --bg-fill --no-fehbg" time_format="%H:%M:%S" + # Storing current state of dunst before locking + dunst_paused_state="$(dunstctl is-paused)" + # read user config USER_CONF="$HOME/.config/betterlockscreenrc" if [ -e "$USER_CONF" ]; then @@ -82,8 +85,8 @@ prelock() { if [ "$DEFAULT_DPMS" == "Enabled" ]; then xset dpms "$lock_timeout" fi - # pause dunst - if command -v dunstctl &>/dev/null + # If dusnt is already paused don't pause it again + if [[ -e "$(command -v dunstctl)" && "$dunst_paused_state" == "false" ]] then dunstctl set-paused true fi @@ -149,8 +152,8 @@ postlock() { xset dpms "$DEFAULT_TIMEOUT" fi - # unpause dunst - if command -v dunstctl &>/dev/null + # If dunst already paused before locking don't unpause dunst + if [[ -e "$(command -v dunstctl)" && "$dunst_paused_state" == "false" ]] then dunstctl set-paused false fi