/usr/share/laptop-mode-tools/modules/wireless-power is in laptop-mode-tools 1.64-1ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | #! /bin/sh
#
# Laptop mode tools module, called from /usr/sbin/laptop_mode.
# Configuration in /etc/laptop-mode/conf.d/wireless-power.conf.
#
# PURPOSE: power saving for generic wireless adapters that support
# the iwconfig power command.
#
[ "$WIRELESS_POWER_SAVING_EXCLUDE_DRIVERS" ] || WIRELESS_POWER_SAVING_EXCLUDE_DRIVERS="iwl3945 iwl4965 iwlagn ipw3945 ipw2200 ipw2100"
#
# Find all the wireless devices that do not use an excluded driver.
# Place the interface names on the list WIFI_IFNAMES.
#
findWifiIfs () {
local SYSDEVICE EXCLUDED LINK_TARGET DRIVER IFNAME EXCLUDED_DRIVER;
for SYSDEVICE in /sys/class/net/*; do
IFNAME=`basename $SYSDEVICE`
# Check if it is a wireless device
#
# Inverting return values, we get "0" for wireless device,
# and "1" for non-wireless device.
($IWCONFIG $IFNAME 2>&1 | grep -q "no wireless extensions.") && ret=1 || ret=0
if [ "$ret" = "0" ]; then
# Yes, it is a wireless device.
if [ -h $SYSDEVICE/device/driver ]; then
# Read the driver name
LINK_TARGET=`readlink $SYSDEVICE/device/driver`
DRIVER=${LINK_TARGET##*/}
EXCLUDED=0
for EXCLUDED_DRIVER in $WIRELESS_POWER_SAVING_EXCLUDE_DRIVERS ; do
if [ "$EXCLUDED_DRIVER" = "$DRIVER" ] ; then
log "VERBOSE" "Wireless interface $IFNAME excluded for wireless-power by driver name."
EXCLUDED=1
fi
done
if [ $EXCLUDED = 0 ] ; then
# add the interface name to the list
WIFI_IFNAMES="$WIFI_IFNAMES $IFNAME"
fi
fi
fi
done
}
if [ x$CONTROL_WIRELESS_POWER_SAVING = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_WIRELESS_POWER_SAVING = xauto ]; then
log "VERBOSE" "Setting power saving for generic wireless interfaces."
# Provide defaults for config file settings
[ "$WIRELESS_AC_POWER_SAVING" ] || WIRELESS_AC_POWER_SAVING=0
[ "$WIRELESS_BATT_POWER_SAVING" ] || WIRELESS_BATT_POWER_SAVING=1
# Find executables
if [ -x /sbin/iwconfig ] ; then
IWCONFIG=/sbin/iwconfig
elif [ -x /usr/sbin/iwconfig ] ; then
IWCONFIG=/usr/sbin/iwconfig
else
log "VERBOSE" "iwconfig is not installed"
IWCONFIG=/bin/false
fi
# Translate 1 => on, 0 => off
WIRELESS_AC_POWER_SAVING_ONOFF=off
WIRELESS_BATT_POWER_SAVING_ONOFF=off
[ "$WIRELESS_AC_POWER_SAVING" = 1 ] && WIRELESS_AC_POWER_SAVING_ONOFF=on
[ "$WIRELESS_BATT_POWER_SAVING" = 1 ] && WIRELESS_BATT_POWER_SAVING_ONOFF=on
WIFI_IFNAMES=""
findWifiIfs
for IF in $WIFI_IFNAMES ; do
if [ $ON_AC -eq 1 ] ; then
log "VERBOSE" "On AC power: setting power saving mode for $IF to $WIRELESS_AC_POWER_SAVING_ONOFF."
if ( ! $IWCONFIG $IF power $WIRELESS_AC_POWER_SAVING_ONOFF ) ; then
log "ERR" "Failed."
fi
else
log "VERBOSE" "On battery: setting power saving mode for $IF to $WIRELESS_BATT_POWER_SAVING_ONOFF."
if ( ! $IWCONFIG $IF power $WIRELESS_BATT_POWER_SAVING_ONOFF ) ; then
log "ERR" "Failed."
fi
fi
done
else
log "VERBOSE" "Generic wireless interface power saving module is disabled."
fi
|