summaryrefslogtreecommitdiff
path: root/users/kassouni/desktop/xmonad/xbindkeys.nix
blob: 41ef7eda1c041210de9855122d84350403099a33 (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
{ pkgs, ... }:
let
  wpctl = "${pkgs.wireplumber}/bin/wpctl";

  xbindkeysrc = pkgs.writeText "xbindkeysrc" ''
    "${wpctl} set-volume -l 1.0 @DEFAULT_AUDIO_SINK@ 5%+"
      XF86AudioRaiseVolume

    "${wpctl} set-volume @DEFAULT_AUDIO_SINK@ 5%-"
      XF86AudioLowerVolume

    "${wpctl} set-mute @DEFAULT_AUDIO_SINK@ toggle"
      XF86AudioMute
  '';
in
{
  systemd.user.services.xbindkeys = {
    Unit = {
      Description = "xbindkeys";
      PartOf = [ "graphical-session.target" ];
      After = [ "graphical-session.target" ];
    };

    Service = {
      # -n keeps it in the foreground so systemd can supervise it
      ExecStart = "${pkgs.xbindkeys}/bin/xbindkeys -n -f ${xbindkeysrc}";
      Restart = "on-failure";
    };

    Install.WantedBy = [ "graphical-session.target" ];
  };
}