From b6386b6094f30a0fc873deb0ec89fd0544613f73 Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 2 Feb 2026 20:25:59 +0100 Subject: [PATCH] feat: wacom tablet integration This is.. filled with hacks. But it works, and is in the `blueplum.nix` file, which is specialized for my machine anyways. --- blueplum.nix | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/blueplum.nix b/blueplum.nix index 2fef259..d5b2124 100644 --- a/blueplum.nix +++ b/blueplum.nix @@ -7,9 +7,45 @@ let concat = strings: builtins.concatStringsSep " " strings; + wacom.src = + let + xsetwacom = "${pkgs.xf86_input_wacom}/bin/xsetwacom"; + awk = lib.getExe pkgs.gawk; + in + '' + #!/bin/sh + + # Wait for X socket + for i in $(seq 30); do + [ -S /tmp/.X11-unix/X0 ] && break + sleep 0.5 + done + + # Just to be sure that the displays are ready... + sleep 5 + + export DISPLAY=:0 + export XAUTHORITY="$HOME/.Xauthority" + + for i in $(seq 10); do + if ${xsetwacom} list devices | grep -q Wacom; then + break + fi + sleep 1 + done + + stylus=$(${xsetwacom} list devices | ${awk} -F' \t' '/stylus/{print $1}') + + if [ -z "$${stylus}" ]; then + exit 0 + fi + + ${xsetwacom} set "$stylus" MapToOutput HEAD-0 + ''; in { services.xserver.videoDrivers = [ "nvidia" ]; + services.xserver.wacom.enable = true; hardware.nvidia = { modesetting.enable = true; @@ -37,4 +73,19 @@ in "--rate 144" ]}" ]; + + systemd.user.services.wacom = { + enable = true; + description = "Configure my Wacom (One) tablet"; + wantedBy = [ "default.target" ]; + after = [ "graphical-session.target" ]; + serviceConfig = { + Type = "oneshot"; + ExecStart = pkgs.writeShellScript "wacom.sh" wacom.src; + }; + }; + + services.udev.extraRules = '' + ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="056a", TAG+="systemd", ENV{SYSTEMD_USER_WANTS}+="wacom.service" + ''; }