💾 Archived View for tdem.in › post › dunst-toggle.gmi captured on 2023-09-08 at 15:55:10. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-06-03)
-=-=-=-=-=-=-
2020-08-12 18:02
In case you always wanted to write a script that temporarily turns off dunst notifications in i3wm but have never taken the time to write one yourself, here, have a working implementation in bash.
`${HOME}/.local/bin/dunst_toggle.sh`:
#!/usr/bin/env bash notify="notify-send -u low dunst" case `dunstctl is-paused` in true) dunstctl set-paused false $notify "Notifications are enabled" ;; false) $notify "Notifications are paused" # the delay is here because pausing notifications immediately hides # the ones present on your desktop; we also run dunstctl close so # that the notification doesn't reappear on unpause (sleep 3 && dunstctl close && dunstctl set-paused true) & ;; esac
Now let's add a hotkey that toggles notifications in i3 config:
`${HOME}/.config/i3/config`:
bindsym $mod+F5 exec --no-startup-id ~/.local/bin/dunst_toggle.sh
That's it, pressing Win + F5 will now toggle notifications on/off. Any notifications received during downtime will be shown as soon as dunst is unpaused.