From 1f5297bf737560fa2dd886fbb8cb94331cccf93a Mon Sep 17 00:00:00 2001 From: Akshay Date: Sat, 23 Sep 2023 21:50:03 +0530 Subject: notify on brightness and volume change --- services/dunst.nix | 11 +++++++---- services/sxhkd.nix | 29 +++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/services/dunst.nix b/services/dunst.nix index 0d05889..407820f 100644 --- a/services/dunst.nix +++ b/services/dunst.nix @@ -41,27 +41,30 @@ with theme; mouse_left_click = "close_current"; mouse_middle_click = "do_action, close_current"; mouse_right_click = "close_all"; + gap_size = 12; + progress_bar_height = 4; + progress_bar_corner_radius = 4; }; urgency_normal = { background = base00; foreground = base05; frame_color = base01; - timeout = 10; + timeout = 5; }; urgency_low = { background = base00; foreground = base05; frame_color = base01; - timeout = 2; + timeout = 3; }; urgency_critical = { background = base0C; foreground = base00; - frame_color = base00; - timeout = 0; + frame_color = base0C; + timeout = 5; }; }; }; diff --git a/services/sxhkd.nix b/services/sxhkd.nix index 19d6917..3bb3da8 100644 --- a/services/sxhkd.nix +++ b/services/sxhkd.nix @@ -4,17 +4,34 @@ , ... }: +let + progress = text: value: + '' + ${pkgs.libnotify}/bin/notify-send ${text} -h int:value:${value} -h string:synchronous:volume -h string:hlcolor:"${theme.base0C}" + ''; + brightness = pkgs.writeScriptBin "brightness" '' + ${pkgs.light}/bin/light $@ + v=$(${pkgs.light}/bin/light -G) + ${progress "brightness" "$v"} + ''; + volume = pkgs.writeScriptBin "volume" '' + ${pkgs.alsaUtils}/bin/amixer $@ + v=$(${pkgs.alsaUtils}/bin/amixer sget Master | ${pkgs.gawk}/bin/awk -F"[][%]" '/Left:/ {print $2}') + ${progress "volume" "$v"} + ''; + +in { services.sxhkd = { enable = true; keybindings = { - "super + slash" = "${pkgs.light}/bin/light -A 5"; - "super + shift + slash" = "${pkgs.light}/bin/light -U 5"; - "super + semicolon" = "${pkgs.alsaUtils}/bin/amixer sset Master 2%+"; - "super + shift + semicolon" = "${pkgs.alsaUtils}/bin/amixer sset Master 2%-"; - "super + space" = "${pkgs.dunst}/bin/dunstctl close"; - "super + ctrl + space" = "${pkgs.dunst}/bin/dunstctl close-all"; + "super + slash" = "${brightness}/bin/brightness -A 2"; + "super + shift + slash" = "${brightness}/bin/brightness -U 2"; + "super + semicolon" = "${volume}/bin/volume sset Master 2%+"; + "super + shift + semicolon" = "${volume}/bin/volume sset Master 2%-"; + "super + ctrl + space" = "${pkgs.dunst}/bin/dunstctl close"; "super + shift + space" = "${pkgs.dunst}/bin/dunstctl history-pop"; + "super + ctrl + shift + space" = "${pkgs.dunst}/bin/dunstctl close-all"; }; }; } -- cgit v1.2.3