A simple way to launch an application when a gamepad connects
Note: as it currently exists, this is written for and only tested on a particular Debian 11 system. It may or may not work on others without modification.
There are three components:
gamepad_launcher.service
when triggered.steam_bigpicture.service
for "natively"-installed Steam.steam_bigpicture.flatpak.service
for Flatpak-installed Steam.steam_bigpicture.flatpak.peruser.service
for Flatpak per-user-installed Steam (flatpak --user install ...
).steamlink.service
for "natively"-install SteamLink (I think this is only applicable to Raspberry Pis).steamlink.flatpak.service
for Flatpak-installed SteamLink.steamlink.flatpak.peruser.service
for Flatpak per-user-install SteamLink (flatpak --user install ...
).Manual installation is as follows:
$ mkdir -p ~/.config/systemd/user
$ cp systemd/* ~/.config/systemd/user/
$ systemctl --user enable <selected_application_service.service>
$ systemctl --user daemon-reload
# cp udev/99-gamepads.rules /etc/udev/rules.d/
# udevadm control --reload
Restarting the xow service, if used (to connect Xbox One / Series controllers to the USB wireless dongle), should turn the controllers off. However, restarting the service normally requires root permissions.
To get around this, a NOPASSWD line can be added to the sudoers file (or an included file in the appropriate directory).
The recommended way is to run sudo visudo /etc/sudoers.d/gamepads
and add the following line:
%video ALL = (root) NOPASSWD: /usr/bin/systemctl restart xow
and then any user who is a member of the group "video" should be able to restart xow without a password. Explaining why the visudo command should be used is outside the scope of this README; just know that you risk seriously screwing up your system if you don't.