{ pkgs , lib , inputs , system , ... }: let att_menu = inputs.att_menu.packages.${system}.default; att_wm = inputs.att_wm.packages.${system}.default; attwmctl = pkgs.writeShellScriptBin "attwmctl" '' exec ${att_wm}/bin/att_wmctl "$@" ''; tablet_mode = pkgs.writeShellScriptBin "tablet-mode" (builtins.readFile ./tablet-mode.sh); in { home.packages = [ att_menu attwmctl tablet_mode ]; systemd.user.services = { att_menu = { Unit = { Description = "att_menu touch panel (tablet mode)"; PartOf = [ "graphical-session.target" ]; After = [ "graphical-session.target" ]; StartLimitIntervalSec = 0; }; Service = { ExecStart = lib.getExe att_menu; Restart = "on-failure"; RestartSec = 3; }; }; tablet-mode = { Unit = { Description = "Run the tablet-only services while the machine is folded"; PartOf = [ "graphical-session.target" ]; After = [ "graphical-session.target" ]; }; Service = { Environment = [ "PATH=${lib.makeBinPath [ pkgs.evtest pkgs.coreutils pkgs.systemd pkgs.bash ]}" ]; ExecStart = '' ${tablet_mode}/bin/tablet-mode \ --on 'systemctl --user start att_menu.service squeekboard.service' \ --off 'systemctl --user stop att_menu.service squeekboard.service' ''; Restart = "always"; RestartSec = 5; }; Install.WantedBy = [ "graphical-session.target" ]; }; }; }