Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #Steam Deck Auto Disable Steam Controller by scawp
- #License: DBAD: https://github.com/scawp/Steam-Deck.Auto-Disable-Steam-Controller/blob/main/LICENSE.md
- #Source: https://github.com/scawp/Steam-Deck.Auto-Disable-Steam-Controller
- # Use at own Risk!
- set -e
- script_install_dir="/home/deck/.local/share/scawp/SDADSC"
- conf_dir="$script_install_dir/conf"
- tmp_dir="/tmp/scawp/SDADSC"
- mkdir -p "$tmp_dir" "$conf_dir"
- debug=0
- action="$1"
- device_name=$(sed 's/[.[\*^$]/_/g' <<<"$2")
- if [ "$3" = "3/28de/11ff/1" ] || [ "$3" = "3/28de/1205/111" ]; then
- #Steam converts all inputs to virtual 360 pads with id 3/28de/11ff/1 (I hope!) and its own inputs have id 3/28de/1205/111, ignore.
- [ "$debug" = 1 ] && echo "$(date +'%F %T') - $1 - $2 ($device_name) - $3 --- IGNORING" >> "$script_install_dir/debug.log"
- exit 0
- else
- [ "$debug" = 1 ] && echo "$(date +'%F %T') - $1 - $2 ($device_name) - $3" >> "$script_install_dir/debug.log"
- fi
- if [ ! -f "$conf_dir/disabled" ]; then
- if [ "$action" = "disable" ] && grep -q "^$device_name$" "$conf_dir/simple_device_list.txt"; then
- if [ ! -f "$tmp_dir/controller_id.txt" ]; then
- echo "$(date +'%F %T') - Disabling internal controller because '$device_name' was connected." >> "$script_install_dir/action.log"
- echo "3-3:1.0" > /sys/bus/usb/drivers/usbhid/unbind
- echo "3-3:1.1" > /sys/bus/usb/drivers/usbhid/unbind
- echo "3-3:1.2" > /sys/bus/usb/drivers/usbhid/unbind
- else
- echo "$(date +'%F %T') - '$device_name' was connected but internal controller is already disabled. Adding to wait list." >> "$script_install_dir/action.log"
- fi
- echo "$device_name" >> "$tmp_dir/controller_id.txt"
- elif [ "$action" = "enable" ] && [ -f "$tmp_dir/controller_id.txt" ] && grep -qi "^$device_name$" "$tmp_dir/controller_id.txt"; then
- sed -i "0,/^$device_name$/{//d}" "$tmp_dir/controller_id.txt"
- if [ ! -s "$tmp_dir/controller_id.txt" ]; then
- echo "$(date +'%F %T') - Enabling internal controller because '$device_name' was disconnected." >> "$script_install_dir/action.log"
- rm "$tmp_dir/controller_id.txt"
- echo "3-3:1.0" > /sys/bus/usb/drivers/usbhid/bind
- echo "3-3:1.1" > /sys/bus/usb/drivers/usbhid/bind
- echo "3-3:1.2" > /sys/bus/usb/drivers/usbhid/bind
- else
- echo "$(date +'%F %T') - '$device_name' was disconnected but internal controller is kept disabled because other controllers are still connected. Removing from wait list." >> "$script_install_dir/action.log"
- fi
- elif [ "$action" = "enable" ] && ! grep -q "^#\\?$device_name$" "$conf_dir/simple_device_list.txt"; then
- echo "#$device_name" >> "$conf_dir/simple_device_list.txt"
- echo "$(date +'%F %T') - '$device_name' was connected for the first time and added to '$conf_dir/simple_device_list.txt'. Remove the prefixed '#' to enable the script for it." >> "$script_install_dir/action.log"
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement