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