From b3f457340d01907f09aedd13bbbfed49a50a4549 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 21 Jun 2024 16:19:55 +0200 Subject: [PATCH] Add toggle-notifications script & notification keybinds --- .../graphical/wms/hyprland/config/keybinds.nix | 7 +++++-- home/programs/graphical/wms/hyprland/default.nix | 1 + .../graphical/wms/hyprland/packages/default.nix | 1 + .../packages/toggle-notifications/default.nix | 15 +++++++++++++++ .../toggle-notifications/toggle-notifications.sh | 10 ++++++++++ 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 home/programs/graphical/wms/hyprland/packages/toggle-notifications/default.nix create mode 100644 home/programs/graphical/wms/hyprland/packages/toggle-notifications/toggle-notifications.sh diff --git a/home/programs/graphical/wms/hyprland/config/keybinds.nix b/home/programs/graphical/wms/hyprland/config/keybinds.nix index 27a5760..5ae8a89 100644 --- a/home/programs/graphical/wms/hyprland/config/keybinds.nix +++ b/home/programs/graphical/wms/hyprland/config/keybinds.nix @@ -74,8 +74,11 @@ # # Notifications # - # TODO: Requires notification daemon (dunst?) - + "CTRL, grave, exec, dunstctl close" + "CTRL_SHIFT, grave, exec, dunstctl close-all" + "CTRL, period, exec, dunstctl history-pop" + "CTRL_SHIFT, period, exec, dunstctl context" + "SUPER_SHIFT, D, exec, toggle-notifications" # # Window groups diff --git a/home/programs/graphical/wms/hyprland/default.nix b/home/programs/graphical/wms/hyprland/default.nix index 5ad154e..6c31cf0 100644 --- a/home/programs/graphical/wms/hyprland/default.nix +++ b/home/programs/graphical/wms/hyprland/default.nix @@ -20,6 +20,7 @@ in { hyprPkgs.hyprland-screenshot hyprPkgs.quick-record hyprPkgs.toggle-fake-fullscreen + hyprPkgs.toggle-notifications hyprPkgs.brightness pkgs.brightnessctl pkgs.hyprpicker diff --git a/home/programs/graphical/wms/hyprland/packages/default.nix b/home/programs/graphical/wms/hyprland/packages/default.nix index ea0fc72..2f15f04 100644 --- a/home/programs/graphical/wms/hyprland/packages/default.nix +++ b/home/programs/graphical/wms/hyprland/packages/default.nix @@ -8,6 +8,7 @@ hyprland-screenshot = pkgs.callPackage ./hyprland-screenshot {}; quick-record = pkgs.callPackage ./quick-record {}; toggle-fake-fullscreen = pkgs.callPackage ./toggle-fake-fullscreen {}; + toggle-notifications = pkgs.callPackage ./toggle-notifications {}; }; in packages diff --git a/home/programs/graphical/wms/hyprland/packages/toggle-notifications/default.nix b/home/programs/graphical/wms/hyprland/packages/toggle-notifications/default.nix new file mode 100644 index 0000000..bf909f0 --- /dev/null +++ b/home/programs/graphical/wms/hyprland/packages/toggle-notifications/default.nix @@ -0,0 +1,15 @@ +{pkgs, ...}: +pkgs.writeShellApplication { + name = "toggle-notifications"; + runtimeInputs = with pkgs; [ + coreutils + libnotify + dunst + ]; + text = '' + ${builtins.readFile ./toggle-notifications.sh} + ''; +} + + + diff --git a/home/programs/graphical/wms/hyprland/packages/toggle-notifications/toggle-notifications.sh b/home/programs/graphical/wms/hyprland/packages/toggle-notifications/toggle-notifications.sh new file mode 100644 index 0000000..b3d3313 --- /dev/null +++ b/home/programs/graphical/wms/hyprland/packages/toggle-notifications/toggle-notifications.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +if [ "$(dunstctl is-paused)" = "false" ]; then + notify-send "Notifications" "Pausing notifications..." -h string:x-canonical-private-synchronous:notif-pause + sleep 2 + dunstctl set-paused true +else + dunstctl set-paused false + notify-send "Notifications" "Notifications enabled" -h string:x-canonical-private-synchronous:notif-pause +fi