Skip to content

Commit

Permalink
actkbd module: move sound.mediaKeys options to services.actkbd.volume…
Browse files Browse the repository at this point in the history
…Control
  • Loading branch information
gnidorah committed Mar 31, 2019
1 parent 4d4b67b commit 4cd3e6c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 48 deletions.
2 changes: 2 additions & 0 deletions nixos/modules/rename.nix
Expand Up @@ -126,6 +126,8 @@ with lib;

# alsa
(mkRenamedOptionModule [ "sound" "enableMediaKeys" ] [ "sound" "mediaKeys" "enable" ])
(mkRenamedOptionModule [ "sound" "mediaKeys" "enable" ] [ "services" "actkbd" "volumeControl" "enable" ])
(mkRenamedOptionModule [ "sound" "mediaKeys" "volumeStep" ] [ "services" "actkbd" "volumeControl" "step" ])

# postgrey
(mkMergedOptionModule [ [ "services" "postgrey" "inetAddr" ] [ "services" "postgrey" "inetPort" ] ] [ "services" "postgrey" "socket" ] (config: let
Expand Down
47 changes: 0 additions & 47 deletions nixos/modules/services/audio/alsa.nix
Expand Up @@ -46,36 +46,6 @@ in
'';
};

mediaKeys = {

enable = mkOption {
type = types.bool;
default = false;
description = ''
Whether to enable volume and capture control with keyboard media keys.
You want to leave this disabled if you run a desktop environment
like KDE, Gnome, Xfce, etc, as those handle such things themselves.
You might want to enable this if you run a minimalistic desktop
environment or work from bare linux ttys/framebuffers.
Enabling this will turn on <option>services.actkbd</option>.
'';
};

volumeStep = mkOption {
type = types.string;
default = "1";
example = "1%";
description = ''
The value by which to increment/decrement volume on media keys.
See amixer(1) for allowed values.
'';
};

};

};

};
Expand Down Expand Up @@ -112,23 +82,6 @@ in
};
};

services.actkbd = mkIf config.sound.mediaKeys.enable {
enable = true;
bindings = [
# "Mute" media key
{ keys = [ 113 ]; events = [ "key" ]; command = "${alsaUtils}/bin/amixer -q set Master toggle"; }

# "Lower Volume" media key
{ keys = [ 114 ]; events = [ "key" "rep" ]; command = "${alsaUtils}/bin/amixer -q set Master ${config.sound.mediaKeys.volumeStep}- unmute"; }

# "Raise Volume" media key
{ keys = [ 115 ]; events = [ "key" "rep" ]; command = "${alsaUtils}/bin/amixer -q set Master ${config.sound.mediaKeys.volumeStep}+ unmute"; }

# "Mic Mute" media key
{ keys = [ 190 ]; events = [ "key" ]; command = "${alsaUtils}/bin/amixer -q set Capture toggle"; }
];
};

};

}
45 changes: 44 additions & 1 deletion nixos/modules/services/hardware/actkbd.nix
Expand Up @@ -83,7 +83,7 @@ in
See <command>actkbd</command> <filename>README</filename> for documentation.
The example shows a piece of what <option>sound.enableMediaKeys</option> does when enabled.
The example shows a piece of what <option>services.actkbd.volumeControl.enable</option> does when enabled.
'';
};

Expand All @@ -95,6 +95,34 @@ in
'';
};

volumeControl = {

enable = mkOption {
type = types.bool;
default = false;
description = ''
Whether to enable ALSA volume and capture control with keyboard media keys.
You want to leave this disabled if you run a desktop environment
like KDE, Gnome, Xfce, etc, as those handle such things themselves.
You might want to enable this if you run a minimalistic desktop
environment or work from bare linux ttys/framebuffers.
'';
};

step = mkOption {
type = types.string;
default = "1";
example = "1%";
description = ''
The value by which to increment/decrement volume on media keys.
See amixer(1) for allowed values.
'';
};

};

};

};
Expand Down Expand Up @@ -128,6 +156,21 @@ in
# For testing
environment.systemPackages = [ pkgs.actkbd ];

services.actkbd.bindings = []
++ optionals cfg.volumeControl.enable [
# "Mute" media key
{ keys = [ 113 ]; events = [ "key" ]; command = "${pkgs.alsaUtils}/bin/amixer -q set Master toggle"; }

# "Lower Volume" media key
{ keys = [ 114 ]; events = [ "key" "rep" ]; command = "${pkgs.alsaUtils}/bin/amixer -q set Master ${cfg.volumeControl.step}- unmute"; }

# "Raise Volume" media key
{ keys = [ 115 ]; events = [ "key" "rep" ]; command = "${pkgs.alsaUtils}/bin/amixer -q set Master ${cfg.volumeControl.step}+ unmute"; }

# "Mic Mute" media key
{ keys = [ 190 ]; events = [ "key" ]; command = "${pkgs.alsaUtils}/bin/amixer -q set Capture toggle"; }
];

};

}

0 comments on commit 4cd3e6c

Please sign in to comment.