miku: Disable keypad lights with gamemode
This commit is contained in:
@@ -7,7 +7,15 @@ in {
|
||||
enable = lib.mkEnableOption "Enable and configure gamemode";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
config = let
|
||||
keyboardBrightnessScript = pkgs.writeShellScript "keyboard-brightness.sh" ''
|
||||
${pkgs.rgb_keyboard}/bin/rgb_keyboard -l ripple -b "$1"
|
||||
'';
|
||||
in lib.mkIf cfg.enable {
|
||||
security.sudo.extraConfig = ''
|
||||
${config.ptw.system.singleUser} ALL = (ALL) NOPASSWD: ${keyboardBrightnessScript}
|
||||
'';
|
||||
|
||||
programs.gamemode = {
|
||||
enable = true;
|
||||
enableRenice = true;
|
||||
@@ -29,14 +37,28 @@ in {
|
||||
};
|
||||
|
||||
custom = let
|
||||
switchScript = groupName: pkgs.writeShellScript "switch-input-group.sh" ''
|
||||
${pkgs.dbus}/bin/dbus-send --print-reply --dest=org.fcitx.Fcitx5 /controller org.fcitx.Fcitx.Controller1.SwitchInputMethodGroup string:'${groupName}'
|
||||
'';
|
||||
switchScript = groupName: "${pkgs.dbus}/bin/dbus-send --print-reply --dest=org.fcitx.Fcitx5 /controller org.fcitx.Fcitx.Controller1.SwitchInputMethodGroup string:'${groupName}'";
|
||||
pauseFcitx = switchScript "Group 2";
|
||||
resumeFcitx = switchScript "Group 1";
|
||||
|
||||
# The scripts
|
||||
start = pkgs.writeShellScript "gamemode-start.sh" ''
|
||||
# Disable Fcitx's IME
|
||||
${pauseFcitx}
|
||||
|
||||
# Turn on the keyboard lights
|
||||
${config.security.wrapperDir}/sudo ${keyboardBrightnessScript} 1
|
||||
'';
|
||||
end = pkgs.writeShellScript "gamemode-end.sh" ''
|
||||
# Resume Fcitx's IME
|
||||
${resumeFcitx}
|
||||
|
||||
# Turn off the keyboard lights
|
||||
${config.security.wrapperDir}/sudo ${keyboardBrightnessScript} 0
|
||||
'';
|
||||
in {
|
||||
start = ''${pauseFcitx}'';
|
||||
end = ''${resumeFcitx}'';
|
||||
start = "${start}";
|
||||
end = "${end}";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user