Add toggle-notifications script & notification keybinds

This commit is contained in:
ItsDrike 2024-06-21 16:19:55 +02:00
parent 3cb701b042
commit b3f457340d
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0
5 changed files with 32 additions and 2 deletions

View file

@ -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

View file

@ -20,6 +20,7 @@ in {
hyprPkgs.hyprland-screenshot
hyprPkgs.quick-record
hyprPkgs.toggle-fake-fullscreen
hyprPkgs.toggle-notifications
hyprPkgs.brightness
pkgs.brightnessctl
pkgs.hyprpicker

View file

@ -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

View file

@ -0,0 +1,15 @@
{pkgs, ...}:
pkgs.writeShellApplication {
name = "toggle-notifications";
runtimeInputs = with pkgs; [
coreutils
libnotify
dunst
];
text = ''
${builtins.readFile ./toggle-notifications.sh}
'';
}

View file

@ -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