Skip to content

Commit

Permalink
refactor(wacom): unified setup-wacom script
Browse files Browse the repository at this point in the history
  • Loading branch information
Wittano committed May 3, 2024
1 parent faf8c80 commit 45ed58d
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions modules/hardware/wacom.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ with lib;
with lib.my;
let
cfg = config.modules.hardware.wacom;
dependecies = strings.makeBinPath (with pkgs;[ xf86_input_wacom gawk ]);
serviceScript = pkgs.writeScript "setup-wacom.sh" /*fish*/''
#!/bin/bash
devices=$(xsetwacom list devices | awk '{print $9}')
for d in $devices; do
xsetwacom --set "$d" MapToOutput HEAD-0
done
'';
name = "setup-wacom";
setupWacom = pkgs.writeShellApplication {
inherit name;

runtimeInputs = with pkgs;[ xf86_input_wacom gawk ];
text = ''
devices=$(xsetwacom list devices | awk '{print $9}')
for d in $devices; do
xsetwacom --set "$d" MapToOutput HEAD-0
done
'';
};
in
{
options = {
Expand All @@ -25,9 +29,9 @@ in
services.xserver.wacom.enable = true;

home-manager.users.wittano = {
home.packages = with pkgs; [ krita ];
home.packages = with pkgs; [ krita setupWacom ];

systemd.user.services."setup-wacom" = {
systemd.user.services.${name} = {
Unit = {
Description = "Map tablet to primary display";
After = [ "graphical-session-pre.target" ];
Expand All @@ -36,20 +40,12 @@ in

Service = {
Type = "oneshot";
ExecStart = "${pkgs.bash}/bin/bash ${serviceScript}";
Environment = [ ''DISPLAY=":0"'' "PATH=${dependecies}" ];
ExecStart = meta.getExe setupWacom;
Environment = [ ''DISPLAY=":0"'' ];
};

Install.WantedBy = [ "graphical-session.target" ];
};

programs.fish.functions.fixWacom.body = /*fish*/ ''
set -l devices (${pkgs.xf86_input_wacom}/bin/xsetwacom list devices | ${pkgs.gawk}/bin/awk '{print $9}')
for d in $devices;
${pkgs.xf86_input_wacom}/bin/xsetwacom --set "$d" MapToOutput HEAD-0
end
'';
};
};
}

0 comments on commit 45ed58d

Please sign in to comment.