Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new input module #123

Merged
merged 38 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3a0e86a
Add new input module with support for setting keyboard layouts
toast003 Apr 11, 2024
27529fa
Update README.md
toast003 Apr 11, 2024
8a3ac86
Add numlock option to the input module
toast003 Apr 11, 2024
13c6504
Merge branch 'pjones:trunk' into libinput
toast003 Apr 24, 2024
3aef026
Merge branch 'pjones:trunk' into libinput
toast003 Apr 28, 2024
d9754f6
Merge branch 'pjones:trunk' into libinput
toast003 Apr 29, 2024
861295f
Merge branch 'trunk' into libinput
toast003 Jun 23, 2024
bda164d
Remove unneeded comment from the input module
toast003 Jun 23, 2024
eba2f7f
Add basic trackpad settings
toast003 Jul 1, 2024
ba0cdea
Do ID hex to dec conversion in write_config.py
toast003 Jul 1, 2024
a1dcafd
Fix windowDecorations options description (#226)
HeitorAugustoLN Jun 24, 2024
0efa15d
Remove the nix-community transfer snippet from the README file (#227)
HeitorAugustoLN Jun 24, 2024
7be657d
Replace mentions of old repo location with the new one
toast003 Jun 24, 2024
97a4637
Add immutableByDefault option (#225)
magnouvean Jun 25, 2024
311271a
Add some more info and some rewrites for the README (#231)
magnouvean Jun 25, 2024
ed17ef4
Fix marginsseparator panel widget typo (#230)
howird Jun 25, 2024
486cfa2
Add extraWidgets option (#233)
HeitorAugustoLN Jun 29, 2024
64960f1
Add application-title-bar widget-specific options (#234)
HeitorAugustoLN Jun 29, 2024
b922fc0
Automatically install third-party widget if it is present in a panel …
HeitorAugustoLN Jun 30, 2024
9062406
Remove leftover reminder and update description in input module
toast003 Jul 1, 2024
d12cb0e
Merge branch 'trunk' into libinput
toast003 Jul 1, 2024
6ace0a4
Merge branch 'trunk' into libinput
toast003 Jul 7, 2024
f5584b8
Minor write_config.py refactoring
toast003 Jul 7, 2024
559f397
Add more trackpad settings to the input module
toast003 Jul 7, 2024
a5d0cc3
Merge branch 'trunk' into libinput
magnouvean Jul 22, 2024
585317f
Add more options, remove need for assertions and add support for mult…
magnouvean Jul 22, 2024
a39e192
Add more touchpad options
magnouvean Jul 22, 2024
d907ce0
Add mouse configuration options
HeitorAugustoLN Jul 22, 2024
6a76b3f
Update hex values to decimal
HeitorAugustoLN Jul 22, 2024
205ec26
Update scrollSpeed example
HeitorAugustoLN Jul 23, 2024
4dc514b
Revert "Update hex values to decimal"
HeitorAugustoLN Jul 24, 2024
f8fd6d6
Update input module examples
toast003 Jul 24, 2024
a46050e
Fix spelling mistake in input module
toast003 Jul 24, 2024
50ab873
Merge pull request #1 from HeitorAugustoLN/mouse-inputs
toast003 Jul 24, 2024
f5e0c69
Update README.md
toast003 Jul 24, 2024
5035496
Merge branch 'trunk' into libinput
toast003 Jul 24, 2024
e8999f6
Fix option name in input
toast003 Jul 24, 2024
72da6a5
Minor description changes
magnouvean Jul 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ At the moment `plasma-manager` supports configuring the following:
- Shortcuts (via the `shortcuts` module)
- Hotkeys (via the `hotkeys` module)
- Panels (via the `panels` module)
- Keyboards (via the `input` module)
- Screen locker (via the `kscreenlocker` module)
- Fonts (via the `fonts` module)
- Window Rules (via the `window-rules` module)
Expand Down
1 change: 1 addition & 0 deletions modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
./windows.nix
./window-rules.nix
./workspace.nix
./input.nix
];

options.programs.plasma.enable = lib.mkEnableOption ''
Expand Down
104 changes: 104 additions & 0 deletions modules/input.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{ config, lib, ... }:

with lib;

let
cfg = config.programs.plasma;
numlockSettings = [ "on" "off" "unchanged" ];
in
{
# Keyboard options
options.programs.plasma.input.keyboard = {
layouts = mkOption {
type = with types; nullOr (listOf str);
default = null;
example = [ "es" "us" ];
description = ''
Keyboard layouts to use.
'';
};
numlockOnStartup = mkOption {
type = with types; nullOr (enum numlockSettings);
default = null;
example = "on";
description = ''
Numpad settings at startup.
'';
};
};

config.programs.plasma.configFile."kxkbrc" = mkIf (cfg.enable) (
mkMerge [
(
mkIf (cfg.input.keyboard.layouts != null) {
Layout = {
Use.value = true;
LayoutList.value = strings.concatStringsSep "," cfg.input.keyboard.layouts;
};
}
)
]
);

# Trackpad options

options.programs.plasma.input.touchpad = {
enable = mkOption {
type = with types; nullOr bool;
default = null;
example = true;
description = ''
Enables or disables the trackpad
'';
};
name = mkOption {
type = with types; nullOr str;
default = null;
example = "PNP0C50:00 0911:5288 Touchpad";
description = ''
The name of the trackpad.
You can find it out running cat /proc/bus/input/devices | grep -i touchpad
'';
};
vendorId = mkOption {
type = with types; nullOr str;
default = null;
example = "2321";
description = ''
The vendor ID of the trackpad
You can find it out running cat /proc/bus/input/devices | grep -i touchpad
'';
};
productId = mkOption {
type = with types; nullOr str;
default = null;
example = "21128";
description = ''
The product ID of the trackpad
You can find it out running cat /proc/bus/input/devices | grep -i touchpad
'';
};
};

config.programs.plasma.configFile."kcminputrc" =
let
touchName = cfg.input.touchpad.name;
touchVendor = cfg.input.touchpad.vendorId;
touchProduct = cfg.input.touchpad.productId;
in
mkIf (cfg.enable) (
mkMerge [
(
# For some reason the numlock settings are here and not on kxkbrc?
mkIf (cfg.input.keyboard.numlockOnStartup != null) {
Keyboard.NumLock.value = lists.findFirstIndex (x: x == cfg.input.keyboard.numlockOnStartup) null numlockSettings;
}
)
(
mkIf (cfg.input.touchpad.enable != null) {
"Libinput/${touchVendor}/${touchProduct}/${touchName}".Enabled.value = cfg.input.touchpad.enable;
}
)
]
);
}
19 changes: 18 additions & 1 deletion script/write_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import re
import sys
import os
from dataclasses import dataclass
from typing import Dict, Optional, Self, Set

Expand Down Expand Up @@ -76,6 +77,21 @@ def escape(s: str) -> str:
s[i] = "\\s"
return "".join(s)

# Some values need to be "transformed", such as being converted from hex to decimal
def transformValues(dOrig):
d = dOrig

cPath = os.path.expanduser("~/.config/kcminputrc")
if cPath in d:
for itemStr in list(d[cPath]):
if itemStr.startswith("Libinput/"):
item = d[cPath].pop(itemStr)
itemStrList = itemStr.split("/")
itemStrList[1] = str(int(itemStrList[1],16))
itemStrList[2] = str(int(itemStrList[2],16))
itemStr = "/".join(itemStrList)
d[cPath][itemStr] = item
return d;

@dataclass
class ConfigValue:
Expand Down Expand Up @@ -329,7 +345,8 @@ def main():

reset_files = set(sys.argv[2].split(" ")) if sys.argv[2] != "" else set()
immutable_by_default = bool(sys.argv[3])
d = json.loads(json_str)
dRaw = json.loads(json_str)
d = transformValues(dRaw)
remove_config_files(d, reset_files)
write_configs(d, reset_files, immutable_by_default)

Expand Down
Loading