Skip to content

Commit

Permalink
Do not report errors on systems with no wifi
Browse files Browse the repository at this point in the history
This change does not attempt to _wifi_set_power_level()
unless /proc/net/wireless exists.

Other changes: fix a typo.

Signed-off-by: Jiri Mencak <[email protected]>
  • Loading branch information
jmencak committed Jan 24, 2024
1 parent b15de12 commit 14d40cf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion profiles/functions
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,16 @@ _wifi_set_power_level() {
# 6 disable power savings
level=$1

# do not report errors on systems with no wireless
[ -e /proc/net/wireless ] || return 0

# apply the settings using iwpriv
ifaces=$(cat /proc/net/wireless | grep -v '|' | sed 's@^ *\([^:]*\):.*@\1@')
for iface in $ifaces; do
iwpriv $iface set_power $level
done

# some adapters may relay on sysfs
# some adapters may rely on sysfs
for i in /sys/bus/pci/devices/*/power_level; do
(echo $level > $i) &> /dev/null
done
Expand Down

0 comments on commit 14d40cf

Please sign in to comment.