Skip to content

Commit 6467493

Browse files
committed
add module to attempt to autodetect and add active input kmods
maybe there is a better way to enumerate this info, in the mean time this helps Signed-off-by: Zen <[email protected]>
1 parent 59fc41c commit 6467493

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/ugrd/kmod/input.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
__version__ = "0.1.0"
2+
3+
from zenlib.util import contains
4+
from zenlib.util import colorize as c_
5+
6+
7+
@contains("kmod_autodetect_input")
8+
def autodetect_input(self):
9+
""" Adds _input_device_kmods to "_kmod_auto" if they are in /proc/modules"""
10+
with open("/proc/modules", "r") as f:
11+
modules = f.read()
12+
13+
for input_kmod in self["_input_device_kmods"]:
14+
if input_kmod in modules:
15+
self["_kmod_auto"] = input_kmod
16+
self.logger.info(f"Autodetected input device kernel module: {c_(input_kmod, 'cyan')}")
17+

src/ugrd/kmod/input.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
kmod_autodetect_input = true
2+
_input_device_kmods = [ "hid_apple", "hid_generic", "usbhid" ]
3+
4+
[imports.build_enum]
5+
"ugrd.kmod.input" = [ "autodetect_input" ]
6+
7+
[import_order.after]
8+
"autodetect_input" = "get_kernel_version"
9+
10+
[custom_parameters]
11+
kmod_autodetect_input = "bool" # Whether or not to detect input devices
12+
_input_device_kmods = "NoDupFlatList" # List of input device kernel modules

src/ugrd/kmod/kmod.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
modules = [ "ugrd.kmod.standard_mask" ]
1+
modules = [ "ugrd.kmod.standard_mask", "ugrd.kmod.input" ]
22

33
binaries = [ "modprobe" ]
44

0 commit comments

Comments
 (0)