This repository has no description
1.3 kB
44 lines
1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7{
8 systemd.services.antimicrox = {
9 after = [ "display-manager.service" ];
10 wantedBy = [ "multi-user.target" ];
11 environment = {
12 DISPLAY = ":0";
13 };
14 serviceConfig = {
15 User = config.users.users.mainUser.name;
16 ExecStartPre = lib.singleton (pkgs.writeDash "init_state" "echo 0 > /tmp/gamepad.state");
17 ExecStart = "${pkgs.antimicrox}/bin/antimicrox --hidden --profile ${./mouse.gamecontroller.amgp}";
18 };
19 };
20
21 services.udev.extraRules = ''
22 KERNEL=="uinput", MODE="0660", GROUP="input", OPTIONS+="static_node=uinput"
23 '';
24
25 environment.systemPackages = [
26 pkgs.antimicrox
27 (pkgs.writers.writeDashBin "gamepad_mouse_disable" ''
28 echo 1 > /tmp/gamepad.state
29 ${pkgs.antimicrox}/bin/antimicrox --profile ${./empty.gamecontroller.amgp}
30 '')
31 (pkgs.writers.writeDashBin "gamepad_mouse_enable" ''
32 echo 0 > /tmp/gamepad.state
33 ${pkgs.antimicrox}/bin/antimicrox --profile ${./mouse.gamecontroller.amgp}
34 '')
35 (pkgs.writers.writeDashBin "gamepad_mouse_toggle" ''
36 state=$(${pkgs.coreutils}/bin/cat /tmp/gamepad.state)
37 if [ "$state" = 1 ]; then
38 /run/current-system/sw/bin/gamepad_mouse_enable
39 else
40 /run/current-system/sw/bin/gamepad_mouse_disable
41 fi
42 '')
43 ];
44}