But when I suspend and resume, the settings aren't remembered. The machine always comes up with wireless active, even if it wasn't before suspending.
Since wireless can be a drain on battery life, as well as a potential security issue, I don't want it on when I'm not actually using it. So I wanted a way to turn it off programmatically.
The answer, it turns out, is rfkill.
$ rfkill list 0: tpacpi_bluetooth_sw: Bluetooth Soft blocked: yes Hard blocked: no 0: phy0: Wireless LAN Soft blocked: yes Hard blocked: notells you what hardware is currently enabled or disabled.
To toggle something off,
$ rfkill block bluetooth $ rfkill block wifi
rfkill -h for more details on arguments you can use.
Fn-F5 still works to enable or disable them together. I think this is being controlled by /etc/acpi/ibm-wireless.sh, though I can't find where it's tied to Fn-F5.
You can make it automatic by creating /etc/pm/sleep.d/. (That's on Ubuntu; of course, the exact file location may vary with distro and version.) To disable wireless on resume, do this:
#! /bin/sh case "$1" in resume) rfkill block bluetooth rfkill block wifi ;; esac exit $?
Of course, you can also tie that into other things, like your current
network scheme, or what wireless networks are visible (which you can
iwlist wlan0 scan).
[ 19:46 Mar 04, 2013 More linux/laptop | permalink to this entry | ]