First, you need a command to set “enabled” to the USB ports.
Quick hack of shell script. Let’s call this /usr/local/bin/usb-standby-power-on.sh
.
#!/bin/bash
for usbport in /sys/bus/usb/devices/usb*/power/wakeup ; do
echo enabled > $usbport
done
exit 0
Then, you need a systemd unit file. Name this /etc/systemd/system/usb-wakeup-enable.service
.
[Unit]
Description=Enable USB's stand-by power
[Service]
Type=oneshot
ExecStart=/usr/local/bin/usb-stanby-power-on.sh
User=root
Group=root
RemainAfterExit=true # Indicates that the service remains active after the main process exits
[Install]
WantedBy=basic.target
Then,
sudo systemctl daemon-reload
sudo systemctl enable usb-wakeup-enable.service
sudo systemctl start usb-wakeup-enable.service