Last active
November 22, 2023 22:51
-
-
Save shmup/b5e187e9e431be07d60fb9446d60bce8 to your computer and use it in GitHub Desktop.
toggles for autolock and dunst notifications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# toggles autolock and dunst notifications | |
# usage: toggle-autolock [start|stop] [-q|--quiet] | |
QUIET_MODE=0 | |
start_autolock() { | |
xautolock -time 2 -locker lock >/dev/null 2>&1 & | |
[[ $QUIET_MODE -eq 0 ]] && echo "😀" | |
} | |
stop_autolock() { | |
kill "$(pgrep -x xautolock)" >/dev/null 2>&1 & | |
[[ $QUIET_MODE -eq 0 ]] && echo "😴" | |
} | |
toggle_autolock() { | |
if pgrep -x xautolock >/dev/null; then | |
stop_autolock | |
else | |
start_autolock | |
fi | |
} | |
for arg in "$@"; do | |
if [ "$arg" = "-q" ] || [ "$arg" = "--quiet" ]; then | |
QUIET_MODE=1 | |
break | |
fi | |
done | |
case "$1" in | |
start) | |
start_autolock | |
;; | |
stop) | |
stop_autolock | |
;; | |
*) | |
toggle_autolock | |
;; | |
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# toggles dunst notifications | |
# usage: toggle-dunst [start|stop] [-q|--quiet] | |
QUIET_MODE=0 | |
start_notifications() { | |
dunstctl set-paused false | |
[[ $QUIET_MODE -eq 0 ]] && echo "😀" | |
} | |
stop_notifications() { | |
dunstctl set-paused true | |
[[ $QUIET_MODE -eq 0 ]] && echo "😴" | |
} | |
toggle_notifications() { | |
if [ "$(dunstctl is-paused)" = "true" ]; then | |
start_notifications | |
else | |
stop_notifications | |
fi | |
} | |
for arg in "$@"; do | |
if [ "$arg" = "-q" ] || [ "$arg" = "--quiet" ]; then | |
QUIET_MODE=1 | |
break | |
fi | |
done | |
case "$1" in | |
start) | |
start_notifications | |
;; | |
stop) | |
stop_notifications | |
;; | |
*) | |
toggle_notifications | |
;; | |
esac |
Author
shmup
commented
Nov 22, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment