Skip to content

Instantly share code, notes, and snippets.

@shmup
Last active November 22, 2023 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shmup/b5e187e9e431be07d60fb9446d60bce8 to your computer and use it in GitHub Desktop.
Save shmup/b5e187e9e431be07d60fb9446d60bce8 to your computer and use it in GitHub Desktop.
toggles for autolock and dunst notifications
#!/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
#!/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
@shmup
Copy link
Author

shmup commented Nov 22, 2023

alias chill='toggle-autolock stop && toggle-dunst stop -q'
alias woke='toggle-autolock start && toggle-dunst start -q'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment