Void Linux workstation powered by niri, Fish and NeoVim. Contains scripts, browser extensions, custom XBPS packages, and typst plugins. git.anhgelus.world/anhgelus/dotfiles
void niri fish neovim nvim vim dotfiles linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(scripts): autostart steam when a controller is inserted

+97
+14
scripts/controller-autostart-steam/,controller-add
··· 1 + #!/usr/bin/env bash 2 + 3 + env_file="$HOME/.config/controller-autostart-steam.env" 4 + 5 + . $env_file 6 + 7 + if [[ -f "$lockfile" ]]; then 8 + echo "lockfile present" 9 + exit 0 10 + fi 11 + 12 + touch "$lockfile" 13 + 14 + XDG_RUNTIME_DIR=/run/user/$(id -u $USER) systemctl --user start controller-steam.service
+13
scripts/controller-autostart-steam/,start-steam
··· 1 + #!/usr/bin/env bash 2 + 3 + env_file="$HOME/.config/controller-autostart-steam.env" 4 + 5 + . $env_file 6 + 7 + powerprofilesctl set "$perf_inside" 8 + 9 + steam 10 + 11 + powerprofilesctl set "$perf_outside" 12 + 13 + rm "$lockfile" || echo "cannot delete $lockfile"
+2
scripts/controller-autostart-steam/99-controller-autostart-steam.rules
··· 1 + # my Xbox 360 controller 2 + ATTR{idVendor}=="0e6f", ATTR{idProduct}=="0413", ACTION=="add", RUN+="/usr/bin/sudo -u anhgelus /home/anhgelus/.local/bin/,controller-add"
+53
scripts/controller-autostart-steam/README.md
··· 1 + # Controller autostart Steam 2 + 3 + Autostart Steam when my controller is plugged. 4 + 5 + Set power profile to `performance` and go back to `power-saving` when Steam is closed. 6 + 7 + ## Installing 8 + 9 + Copy `,controller-add` and `,start-steam` in `$HOME/.local/bin`. 10 + 11 + Copy `99-controller-autostart-steam.rules` in `/etc/udev/rules.d/` and change: 12 + - `anhgelus` by your UNIX username 13 + - `0e6f` by the vendor ID of your controller (displayed by `lsusb`) 14 + - `0413` by the product ID of your controller (displayed by `lsusb`) 15 + 16 + See below if you don't know how to get these IDs. 17 + 18 + Copy `controller-steam.service` in `$HOME/.config/systemd/user/` and change: 19 + - `anhgelus` by your UNIX username 20 + 21 + Copy `controller-autostart-steam.env` in `$HOME/.config`. 22 + 23 + Reload udev rules: 24 + ```bash 25 + sudo udevadm control --reload-rules && sudo udevadm trigger 26 + ``` 27 + 28 + Reload systemd: 29 + ```bash 30 + systemctl --user daemon-reload 31 + ``` 32 + 33 + You can modify the location of the lockfile by editing `lockfile` variable in 34 + `$HOME/.config/controller-autostart-steam.env`. 35 + 36 + You can modify the power profile by editing in the same file: 37 + - `perf_inside` variable when Steam is launched 38 + - `perf_outside` variable when Steam is closed 39 + 40 + ### How to get required IDs of your controller? 41 + 42 + Plug your controller and run: 43 + ```bash 44 + lsusb 45 + ``` 46 + It will list hardwares connected to your computer via a USB port. 47 + 48 + My controller is this one: 49 + ``` 50 + Bus 003 Device 011: ID 0e6f:0413 Logic3 Afterglow AX.1 Gamepad for Xbox 360 51 + ``` 52 + 53 + Its identifier is `0e6f:0413`, where `0e6f` is its vendor ID and `0413` is its product ID.
+6
scripts/controller-autostart-steam/controller-autostart-steam.env
··· 1 + #!/usr/bin/env bash 2 + 3 + lockfile="$HOME/.controller-add.lock" 4 + 5 + perf_inside="performance" 6 + perf_outside="power-saver"
+9
scripts/controller-autostart-steam/controller-steam.service
··· 1 + [Unit] 2 + Description=Autostart Steam when a controller is plugged 3 + 4 + [Service] 5 + Type=simple 6 + ExecStart=/usr/bin/bash /home/anhgelus/.local/bin/,steam-controller 7 + 8 + [Install] 9 + WantedBy=default.target