mirror of
https://git.adityakumar.xyz/betterlockscreen-openrc.git
synced 2024-11-09 10:39:45 +00:00
Check for dunstctl once as dunst is optional dependency (#250)
This commit is contained in:
parent
3c76a7ebfe
commit
709933350c
1 changed files with 8 additions and 7 deletions
|
@ -40,9 +40,6 @@ init_config () {
|
||||||
wallpaper_cmd="feh --bg-fill --no-fehbg"
|
wallpaper_cmd="feh --bg-fill --no-fehbg"
|
||||||
time_format="%H:%M:%S"
|
time_format="%H:%M:%S"
|
||||||
|
|
||||||
# Storing current state of dunst before locking
|
|
||||||
dunst_paused_state="$(dunstctl is-paused)"
|
|
||||||
|
|
||||||
# read user config
|
# read user config
|
||||||
USER_CONF="${XDG_CONFIG_HOME:-$HOME/.config}/betterlockscreenrc"
|
USER_CONF="${XDG_CONFIG_HOME:-$HOME/.config}/betterlockscreenrc"
|
||||||
if [ -e "$USER_CONF" ]; then
|
if [ -e "$USER_CONF" ]; then
|
||||||
|
@ -79,6 +76,10 @@ init_config () {
|
||||||
DEFAULT_TIMEOUT=$(cut -d ' ' -f4 <<< "$(xset q | sed -n '25p')")
|
DEFAULT_TIMEOUT=$(cut -d ' ' -f4 <<< "$(xset q | sed -n '25p')")
|
||||||
# Original DPMS status
|
# Original DPMS status
|
||||||
DEFAULT_DPMS=$(xset q | awk '/^[[:blank:]]*DPMS is/ {print $(NF)}')
|
DEFAULT_DPMS=$(xset q | awk '/^[[:blank:]]*DPMS is/ {print $(NF)}')
|
||||||
|
|
||||||
|
# Dunst
|
||||||
|
DUNST_INSTALLED=false && [[ -e "$(command -v dunstctl)" ]] && DUNST_INSTALLED=true
|
||||||
|
DUNST_IS_PAUSED=false && [[ "$DUNST_INSTALLED" == "true" ]] && DUNST_IS_PAUSED=$(dunstctl is-paused)
|
||||||
}
|
}
|
||||||
|
|
||||||
# called before screen is locked
|
# called before screen is locked
|
||||||
|
@ -88,11 +89,12 @@ prelock() {
|
||||||
if [ "$DEFAULT_DPMS" == "Enabled" ]; then
|
if [ "$DEFAULT_DPMS" == "Enabled" ]; then
|
||||||
xset dpms "$lock_timeout"
|
xset dpms "$lock_timeout"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If dusnt is already paused don't pause it again
|
# If dusnt is already paused don't pause it again
|
||||||
if [[ -e "$(command -v dunstctl)" && "$dunst_paused_state" == "false" ]]
|
if [[ "$DUNST_INSTALLED" == "true" && "$DUNST_IS_PAUSED" == "false" ]]; then
|
||||||
then
|
|
||||||
dunstctl set-paused true
|
dunstctl set-paused true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$runsuspend" = "true" ]]; then
|
if [[ "$runsuspend" = "true" ]]; then
|
||||||
lockargs="$lockargs -n"
|
lockargs="$lockargs -n"
|
||||||
fi
|
fi
|
||||||
|
@ -156,8 +158,7 @@ postlock() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If dunst already paused before locking don't unpause dunst
|
# If dunst already paused before locking don't unpause dunst
|
||||||
if [[ -e "$(command -v dunstctl)" && "$dunst_paused_state" == "false" ]]
|
if [[ "$DUNST_INSTALLED" == "true" && "$DUNST_IS_PAUSED" == "false" ]]; then
|
||||||
then
|
|
||||||
dunstctl set-paused false
|
dunstctl set-paused false
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue