From a00798b058d49e9c0a807f8d824984f16d1a1a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Mon, 18 Apr 2022 12:20:04 +0200 Subject: [PATCH] :rocket: enable asus touchpad numpad --- flake.lock | 17 +++++++++++++++++ flake.nix | 6 ++++++ hosts/nixos-laptop/default.nix | 28 +++++++++++++++++++++++++++- 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/flake.lock b/flake.lock index bc1349c..ee4b1f4 100644 --- a/flake.lock +++ b/flake.lock @@ -18,6 +18,22 @@ "type": "github" } }, + "asus-touchpad-numpad-driver": { + "flake": false, + "locked": { + "lastModified": 1646981564, + "narHash": "sha256-qanPTmP2Sctq4ybiUFzIiADP2gZH8HhajBORUSIXb04=", + "owner": "mohamed-badaoui", + "repo": "asus-touchpad-numpad-driver", + "rev": "a2bada610ebb3fc002fceb53ddf93bc799241867", + "type": "github" + }, + "original": { + "owner": "mohamed-badaoui", + "repo": "asus-touchpad-numpad-driver", + "type": "github" + } + }, "dracula-fish": { "flake": false, "locked": { @@ -303,6 +319,7 @@ "root": { "inputs": { "agenix": "agenix", + "asus-touchpad-numpad-driver": "asus-touchpad-numpad-driver", "dracula-fish": "dracula-fish", "emacs-overlay": "emacs-overlay", "forgit-git": "forgit-git", diff --git a/flake.nix b/flake.nix index 9273df7..05ff6c2 100644 --- a/flake.nix +++ b/flake.nix @@ -33,6 +33,12 @@ # VSCode plugin nix-flake-tools.url = "github:rastertail/nix-flake-tools"; + + # Laptop Touchpad + asus-touchpad-numpad-driver = { + url = "github:mohamed-badaoui/asus-touchpad-numpad-driver"; + flake = false; + }; }; outputs = inputs@{ self, agenix, home-manager, nixpkgs, utils, ... }: diff --git a/hosts/nixos-laptop/default.nix b/hosts/nixos-laptop/default.nix index 776b77e..478410c 100644 --- a/hosts/nixos-laptop/default.nix +++ b/hosts/nixos-laptop/default.nix @@ -2,7 +2,7 @@ # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). -{ config, pkgs, ... }: +{ config, pkgs, inputs, ... }: { imports = [ @@ -78,6 +78,32 @@ script = "${batteryLevelSufficient}/bin/battery-level-sufficient"; }; + # Trackpad + # i2c for https://github.com/mohamed-badaoui/asus-touchpad-numpad-driver + hardware.i2c.enable = true; + systemd.services.asus-touchpad-numpad = { + description = + "Activate Numpad inside the touchpad with top right corner switch"; + documentation = + [ "https://github.com/mohamed-badaoui/asus-touchpad-numpad-driver" ]; + path = [ pkgs.i2c-tools ]; + script = '' + cd ${inputs.asus-touchpad-numpad-driver} + # In the last argument here you choose your layout. + ${ + pkgs.python3.withPackages (ps: [ ps.libevdev ]) + }/bin/python asus_touchpad.py m433ia + ''; + # Probably needed because it fails on boot seemingly because the driver + # is not ready yet. Alternativly, you can use `sleep 3` or similar in the + # `script`. + serviceConfig = { + RestartSec = "1s"; + Restart = "on-failure"; + }; + wantedBy = [ "multi-user.target" ]; + }; + # This value determines the NixOS release from which the default # settings for stateful data, like file locations and database versions # on your system were taken. It‘s perfectly fine and recommended to leave