Skip to content

Instantly share code, notes, and snippets.

@jcberthon
Last active July 20, 2024 11:26
Show Gist options
  • Save jcberthon/ea8cfe278998968ba7c5a95344bc8b55 to your computer and use it in GitHub Desktop.
Save jcberthon/ea8cfe278998968ba7c5a95344bc8b55 to your computer and use it in GitHub Desktop.
NetworkManager Wi-Fi powersaving configuration

NetworkManager WiFi Power Saving

NetworkManager supports WiFi powersaving but the function is rather undocumented.

From the source code: wifi.powersave can have the following value:

  • NM_SETTING_WIRELESS_POWERSAVE_DEFAULT (0): use the default value
  • NM_SETTING_WIRELESS_POWERSAVE_IGNORE (1): don't touch existing setting
  • NM_SETTING_WIRELESS_POWERSAVE_DISABLE (2): disable powersave
  • NM_SETTING_WIRELESS_POWERSAVE_ENABLE (3): enable powersave

Then I propose 2 files, only one of them needs to be put under /etc/NetworkManager/conf.d/.
One is forcing to disable powersaving, while the other one enable it.

Once you have put the file in the right folder, simply restart NetworkManager:

sudo systemctl restart NetworkManager
# File to be place under /etc/NetworkManager/conf.d
[connection]
# Values are 0 (use default), 1 (ignore/don't touch), 2 (disable) or 3 (enable).
wifi.powersave = 2
# File to be place under /etc/NetworkManager/conf.d
[connection]
# Values are 0 (use default), 1 (ignore/don't touch), 2 (disable) or 3 (enable).
wifi.powersave = 3
@YuChuXi
Copy link

YuChuXi commented Jul 20, 2024

有没有办法不用iwconfig来测试配置是否成功?

我尝试禁用 wifi 省电功能:

> cat /etc/NetworkManager/conf.d/wifi-powersave-off.conf
[connection]
wifi.powersave = 2

> sudo systemcl restart NetworkManager

但是 nmcli 没有显示任何变化:

> nmcli con show MIWIFI_FAC2_5G | grep save
802-11-wireless.powersave:              0 (default)

PS:从服务日志来看该文件似乎已被读取:

Jun 27 15:54:31 think NetworkManager[6030]: <info>  [1719496471.3339] Read config: /etc/NetworkManager/NetworkManager.conf (lib: 20-connectivity-fedora.conf, 22-wifi-mac-addr.conf) (etc: wifi-powersave-off.conf)

Me too.
But

[wifi]
powersave=2

is useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment