aboutsummaryrefslogtreecommitdiff
path: root/services/sxhkd.nix
blob: 58b8340b8e1e6a0baca1b12ea5abc9b982407574 (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
38
39
{ 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}"
    '';
  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 =
      let
        vol_up = "${volume}/bin/volume sset Master 2%+";
        vol_down = "${volume}/bin/volume sset Master 2%-";
      in
      {
        "super + slash" = "${pkgs.light}/bin/light -A 2";
        "super + shift + slash" = "${pkgs.light}/bin/light -U 2";
        "super + semicolon" = vol_up;
        "super + shift + semicolon" = vol_down;
        "XF86AudioRaiseVolume" = vol_up;
        "XF86AudioLowerVolume" = vol_down;
        "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";
      };
  };
}