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.
This commit is contained in:
51
blueplum.nix
51
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"
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user