aboutsummaryrefslogtreecommitdiff
path: root/services/sxhkd.nix
blob: 3bb3da82862269e5846ba54ddd4727acba50e642 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{ config
, pkgs
, theme
, ...
}:

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" = "${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";
    };
  };
}