| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | source "$(dirname "$0")/_lib.sh" |
| 4 | |
| 5 | is_dnd() { makoctl mode 2>/dev/null | grep -qx do-not-disturb; } |
| 6 | |
| 7 | case ${1:-toggle} in |
| 8 | toggle) |
| 9 | if is_dnd; then |
| 10 | makoctl mode -r do-not-disturb >/dev/null |
| 11 | notify dnd notifications "Notifications on" |
| 12 | else |
| 13 | notify dnd notifications-disabled "Do Not Disturb on" |
| 14 | sleep 1 |
| 15 | makoctl mode -a do-not-disturb >/dev/null |
| 16 | fi |
| 17 | pkill -RTMIN+8 waybar 2>/dev/null ;; |
| 18 | status) |
| 19 | if is_dnd; then |
| 20 | printf '{"text":"","class":"dnd","tooltip":"Do Not Disturb\\nclick: toggle · right-click: restore last"}\n' |
| 21 | else |
| 22 | printf '{"text":"","class":"normal","tooltip":"Notifications on\\nclick: toggle · right-click: restore last"}\n' |
| 23 | fi ;; |
| 24 | esac |