aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlex <alex.corcoles@veecle.io>2025-03-04 17:01:58 +0100
committeralexpdp7 <alex@corcoles.net>2025-03-04 17:04:09 +0100
commit0d421c43ede5034594b8513ab11766828c46b1dd (patch)
tree48c4555d0dd8e09731ee6435423848fa175c57d9 /scripts
parente11273e79ce361e077551db445463b8462c16290 (diff)
Add setup_x12 script
Diffstat (limited to 'scripts')
-rw-r--r--scripts/p7s/x12.py20
-rw-r--r--scripts/pyproject.toml1
2 files changed, 21 insertions, 0 deletions
diff --git a/scripts/p7s/x12.py b/scripts/p7s/x12.py
new file mode 100644
index 00000000..3fdd1ac6
--- /dev/null
+++ b/scripts/p7s/x12.py
@@ -0,0 +1,20 @@
+import os
+import pathlib
+import subprocess
+import textwrap
+import tempfile
+
+
+def setup_x12():
+ switcher = pathlib.Path(__file__).parent.parent.parent / "linux" / "thinkpad_x12_fn_switcher/"
+ binary = pathlib.Path.home() / ".local" / "bin" / "x12_fn_switcher"
+ subprocess.run(["gcc", switcher / "x12_fn_switcher.c", "-o", binary, "-I/usr/include/libusb-1.0", "-lusb-1.0"], check=True)
+ os.chmod(binary, 0o700)
+ with tempfile.TemporaryDirectory() as tempdir:
+ tempdir = pathlib.Path(tempdir)
+ pathlib.Path(tempdir/ "99-thinkpad-fn.rules").write_text(textwrap.dedent(f"""
+ ACTION=="add", ATTRS{{idVendor}}=="17ef", ATTRS{{idProduct}}=="60fe", RUN+="{binary}"
+ """).lstrip())
+ subprocess.run(["sudo", "cp", tempdir/ "99-thinkpad-fn.rules", "/etc/udev/rules.d/99-thinkpad-fn.rules"], check=True)
+ subprocess.run(["sudo", "udevadm", "control", "--reload-rules"], check=True)
+ subprocess.run(["sudo", "udevadm", "trigger"], check=True)
diff --git a/scripts/pyproject.toml b/scripts/pyproject.toml
index af6196de..c775609b 100644
--- a/scripts/pyproject.toml
+++ b/scripts/pyproject.toml
@@ -29,4 +29,5 @@ setup_bash = 'p7s.bash:setup_bash'
setup_emacs = 'p7s.emacs:setup_emacs'
setup_ubpkg = 'p7s.ubpkg:setup_ubpkg'
setup_paperwm = 'p7s.paperwm:setup_paperwm'
+setup_x12 = 'p7s.x12:setup_x12'
update_zfs = 'p7s.zfs:update_zfs'