贴下我的 code ,可以 work ,但是我的问题是:休眠后过夜就不能唤醒了,过几个小时是没问题的,推测是 powersaving 的问题,但是我的 code 也禁用了。还是不知道问题在哪。
#
https://wiki.debian.org/WakeOnLan#Enabling_WOL active_connection_name=$(nmcli -t -f NAME,DEVICE,TYPE connection show --active | grep -Ev 'tun|loopback|wifi-p2p' | cut -d: -f1)
if [ -n "$active_connection_name" ]; then
# Modify Ethernet WOL if it exists, otherwise Wi-Fi WOL
if nmcli connection show "$active_connection_name" | grep -q 'ethernet'; then
sudo nmcli connection modify "$active_connection_name" 802-3-ethernet.wake-on-lan magic
else
sudo nmcli connection modify "$active_connection_name" wifi.wake-on-wlan magic
# Disable Wi-Fi power save
# WiFi Power Saving:
https://gist.github.com/jcberthon/ea8cfe278998968ba7c5a95344bc8b55 # 0: default (yes or no??), 1: ignore, 2: disable powersave, 3: enable
nmcli con mod "$active_connection_name" 802-11-wireless.powersave 2
# # alternative to nmcli
# sudo cat <<'EOF' | sudo tee /etc/NetworkManager/conf.d/wifi-powersave-off.conf >/dev/null
# [connection]
# # Values are 0 (use default), 1 (ignore/don't touch), 2 (disable) or 3 (enable).
# wifi.powersave = 2
# EOF
# sudo systemctl restart NetworkManager
# check
iw phy0 wowlan show && iwconfig $(nmcli -t -f NAME,DEVICE,TYPE connection show --active | grep -Ev 'tun|loopback|wifi-p2p' | cut -d: -f2)
fi
echo "Wake-on-LAN enabled for connection: $active_connection_name; A restart is required for the changes to take effect."
else
echo "No valid active connection found."
fi