commit dd0288aab9e8268b7ba0841c0985c9d7d78ae0c3 parent 1c32eb89721f6c757fe508f2c5e9b3d42f2f741b Author: Yuval Langer <yuval.langer@gmail.com> Date: Tue, 31 Oct 2023 17:21:02 +0200 Add toggle do-not-disturb scripts. Diffstat:
A | bin/toggle-DND | | | 37 | +++++++++++++++++++++++++++++++++++++ |
A | bin/toggle-DND.sh | | | 18 | ++++++++++++++++++ |
2 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/bin/toggle-DND b/bin/toggle-DND @@ -0,0 +1,37 @@ +#!/usr/bin/env -S guile -e '(toggle-dnd)' -s +!# + +(define-library (toggle-dnd) + (import (guile) + (ice-9 match) + (ice-9 popen) + (ice-9 rdelim) + (ice-9 textual-ports)) + (export main) + + (begin + (define (main args) + (with-input-from-port + (open-pipe* OPEN_READ + "gsettings" + "get" + "org.gnome.desktop.notifications" + "show-banners") + (lambda () + (match (read-line) + ("true" + (format #t "DND turn on.~%") + (system* "gsettings" + "set" + "org.gnome.desktop.notifications" + "show-banners" + "false")) + ("false" + (format #t "DND turn off.~%") + (system* "gsettings" + "set" + "org.gnome.desktop.notifications" + "show-banners" + "true")) + (else + (format #t "Something's wrong! Not a valid answer: ~A\n" current-show-banners-status))) ))))) diff --git a/bin/toggle-DND.sh b/bin/toggle-DND.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +if [ -z "$(command -v gsettings)" ]; then + echo "No gsettings."; + exit 1; +fi + +show_banners_value="$(gsettings get org.gnome.desktop.notifications show-banners)" + +if [ "$show_banners_value" = "true" ]; then + echo "DND turn on." + gsettings set org.gnome.desktop.notifications show-banners false +elif [ "$show_banners_value" = "false" ]; then + echo "DND turn off." + gsettings set org.gnome.desktop.notifications show-banners true +else + echo "Something's wrong! Not a valid show-banner value: $show_banners_value" +fi