Created
January 13, 2021 10:15
-
-
Save dreamcat4/d56ca0d863577bbfef5ed2ea29c2bf36 to your computer and use it in GitHub Desktop.
Disconnect (power off) dualshock 4 controllers from linux cmdline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Disconnect (power off) dualshock 4 controllers from linux cmdline | |
# This command finds and turns off all currently connected dualshock 4 controllers | |
# by sending a usb reset signal to the offical dualshock 4 usb wireless dongle | |
# Reason: because otherwise you have to hold down the PS button for 10-15 seconds | |
# ...which is a really long time to wait! | |
# Note: USB device id is for only the official sony dongle. | |
# Other 3rd party dongles will have a different usb device id | |
_usb_device_id="054c:0ba0" | |
if ! command -v usbreset > /dev/null; then | |
echo "error: missing program dependancy 'usbreset' from package 'usbutils" | |
echo "attempting to install via apt..." | |
sudo apt install -y usbutils || exit 1 | |
fi | |
_ds4_usbs="$(lsusb | grep "$_usb_device_id" | cut -d" " -f2,4 | sed -e "s|:||g" -e "s| |/|g")" | |
for _ds4_usb in $_ds4_usbs; do | |
usbreset $_ds4_usb | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment