Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dunstctl: script, module & preview images #362

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
50 changes: 50 additions & 0 deletions polybar-scripts/dunst-controller/dunstctl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#! /usr/bin/env sh

unmute() {
dunstctl set-paused false && \
dunstify 'dunst' 'Unmuted notifications.' -i polari -u low &
}

mute() {
dunstify 'dunst' 'Muting notifications...' -i polari -u low &
# We're about to mute notifications, so the above notification will
# effectively not show, since set-paused hides notifications. So, sleep
# for 2 seconds.
sleep 2
# Close all to prevent notification from showing up once we unmute.
dunstctl close-all
dunstctl set-paused true
}

pop_all() {
for id in $(dunstctl history | while jq -r '.data[][].id.data'); do
dunstctl history-pop $id
done
aidenlangley marked this conversation as resolved.
Show resolved Hide resolved
}

if [ "$(dunstctl is-paused)" = 'true' ]; then
case $1 in
toggle)
unmute
;;
show-all)
unmute
pop_all
;;
*)
echo " $(dunstctl count waiting)"
;;
esac
else
case $1 in
toggle)
mute
;;
show-all)
pop_all
;;
*)
echo ''
;;
esac
fi