Last active
July 3, 2019 16:32
-
-
Save nexus166/0f8cadeae848d7c01a64371b5f6dba6e to your computer and use it in GitHub Desktop.
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
| #!/usr/bin/env bash | |
| set +xv -eo pipefail | |
| enabled= | |
| for _dev in $(realpath /sys/bus/usb/devices/*/power/wakeup); do | |
| state="$(< ${_dev})"; | |
| printf "[%s]\t%s\n" "${state}" "${_dev}"; | |
| if [[ "${state}" == "enabled" ]]; then | |
| enabled+=" ${_dev}"; | |
| fi | |
| done | |
| for _enabled in ${enabled}; do | |
| printf 'disabled' > "${_enabled}" & printf '\n\nDISABLED\t%s\n' "${_enabled}"; | |
| done | |
| if [[ ! -f /lib/systemd/system/nowakeup.service ]] && [[ "$(id -u)" == 0 ]]; then | |
| cat << 'EOSVC' > /lib/systemd/system/nowakeup.service | |
| [Unit] | |
| Description=DISABLE automatic system WAKEUP with external devices | |
| Before=network-pre.target | |
| After=sysinit.target | |
| [Service] | |
| Type=oneshot | |
| ExecStart=/usr/local/bin/nowakeup | |
| [Install] | |
| WantedBy=basic.target | |
| EOSVC | |
| systemctl enable nowakeup | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment