Skip to content

Instantly share code, notes, and snippets.

@jpcaparas
Last active May 11, 2019 03:49
Show Gist options
  • Save jpcaparas/c49cf455e8e46f8b3ee673ddf482b321 to your computer and use it in GitHub Desktop.
Save jpcaparas/c49cf455e8e46f8b3ee673ddf482b321 to your computer and use it in GitHub Desktop.
systemd service to restart usb ports after suspend (Manjaro)
[Unit]
Description=Restart USB ports after waking up from suspend/hibernate
After=suspend.target hibernate.target
[Service]
Type=oneshot
ExecStart=/opt/usr/bin/reset-usb-ports.sh
[Install]
WantedBy=suspend.target hibernate.target
#!/bin/bash
#see https://forum.manjaro.org/t/keyboard-and-mouse-not-working-after-suspend/61424
#reset all USB1/2/3 ports
for i in /sys/bus/pci/drivers/[uoex]hci_hcd/*:*; do
[ -e "$i" ] || continue
echo "${i##*/}" > "${i%/*}/unbind"
echo "${i##*/}" > "${i%/*}/bind"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment