From a614b877637e844efe23d5303bde04033b8d2e4d Mon Sep 17 00:00:00 2001 From: Szymon P Date: Tue, 24 Feb 2026 21:34:43 +0100 Subject: [PATCH] add do-not-disturb button to ashell --- modules/bars/ashell.nix | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/modules/bars/ashell.nix b/modules/bars/ashell.nix index 33c594d..6bd33bb 100644 --- a/modules/bars/ashell.nix +++ b/modules/bars/ashell.nix @@ -2,10 +2,45 @@ lib, isNixOS, userConfig, + pkgs, ... }: +let + mako-dnd-script = pkgs.writeShellScriptBin "ashell-mako-dnd" '' + case $1 in + listen) + print_state() { + if makoctl mode | grep -q do-not-disturb; then + echo '{"alt":"dnd"}' + else + echo '{"alt":"none"}' + fi + } + + trap print_state USR1 + + print_state + + while true; do + sleep infinity & wait $! + done + ;; + + toggle) + if makoctl mode | grep -q do-not-disturb; then + makoctl mode -r do-not-disturb > /dev/null + else + makoctl mode -a do-not-disturb > /dev/null + fi + + pkill -USR1 -f "ashell-mako-dnd listen" + ;; + esac + ''; +in { + programs.ashell = { enable = true; package = lib.mkIf (!isNixOS) null; @@ -26,12 +61,23 @@ "MediaPlayer" "SystemInfo" [ + "CustomNotifications" "Tray" "Settings" ] ]; }; + CustomModule = [ + { + name = "CustomNotifications"; + icon = ""; + command = "${mako-dnd-script}/bin/ashell-mako-dnd toggle"; + listen_cmd = "${mako-dnd-script}/bin/ashell-mako-dnd listen"; + icons.dnd = ""; + } + ]; + clock = { format = "%H:%M | %e.%m "; };