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/sxhkd.nix | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'services/sxhkd.nix') 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