[Pkg-acpi-devel] Bug#527276: acpi-support: Change Cycling of Wireless Devices

Chris Dos chris at chrisdos.com
Wed May 6 14:09:44 UTC 2009


Package: acpi-support
Version: 0.121-1
Severity: wishlist
Tags: patch

The current method of cycling through the wireless power settings is
very annoying.  If I'm actually on the network, and I need to turn on my
bluetooth, it will most likely turn off the wireless in order to cycle
the power on.  This script is really an addition to the
/etc/acpi/ibm-wireless.sh script.  I feel that if X is running, that an
option should be given for which wireless setting you want to change.
I've tested this on a Thinkpad W500, but I don't see why it wouldn't
work for just about any Thinkpad.

I wrote scripts for this, please take a look at them and modify them to
your needs:

---- Begin /etc/acpi/events/thinkpad_wireless ----
# /etc/acpi/events/thinkpad_wireless
# This is called when the user presses the Fn+F1 button and calls
# /etc/acpi/actions/thinkpad_wireless.sh for further processing.

event=(ibm/hotkey HKEY 00000080 00001005)
action=/etc/acpi/actions/thinkpad_wireless.sh
---- End /etc/acpi/events/thinkpad_wireless ----




---- Begin /etc/acpi/actions/thinkpad_wireless.sh ----
#!/bin/bash

export PATH="/sbin:/usr/sbin:/bin:/usr/bin"

# Check to see if X is running and if not, run the original toggle wireless script
ps ax | grep "/usr/bin/X" | grep -v grep > /dev/null
if [ "$?" != "0" ]
then
        /etc/acpi/ibm-wireless.sh
        exit 0
fi

export DISPLAY=:0
exec /usr/bin/xterm -geometry 80x25+710+450 -name "Toggle Wireless
Settings" /etc/acpi/thinkpad-toggle_wireless.sh
---- End /etc/acpi/actions/thinkpad_wireless.sh ----



---- Begin /etc/acpi/thinkpad-toggle_wireless.sh ----
#!/bin/bash

export PATH="/sbin:/usr/sbin:/bin:/usr/bin"

# Find Wi-Fi device
for DEVICE in /sys/class/net/*
do
if [ -d $DEVICE/wireless ]
then
	WIFINIC="$DEVICE"
fi
done

CHOICE=0
while [ "$CHOICE" != "x" -a "$CHOICE" != "X" ]
do
clear
echo
echo
echo
echo
echo "			Wireless Wi-Fi and Bluetooth Toggle"
echo
echo
echo
echo -n "		$(basename $WIFINIC): "
WIFISTATUS=$(cat $DEVICE/device/rfkill/rfkill0/state)
if [ "$WIFISTATUS" = "1" ]
then
	echo -e -n "\E[32mEnabled\E[37m	"
else
	echo -e -n "\E[31mDisabled\E[37m	"
fi
echo -n "		Bluetooth: "
BTSTATUS=$(head -1 /proc/acpi/ibm/bluetooth | awk {'print $2'})
if [ "$BTSTATUS" = "enabled" ]
then
	echo -e "\E[32mEnabled\E[37m"
else
	echo -e "\E[31mDisabled\E[37m"
fi
echo
echo "		\"W\" to toggle Wi-Fi		\"B\" to toggle
Bluetooth"
echo
echo
echo
echo "				Press \"X\" to quit"
read -s -n1 CHOICE

# Toggle Wireless State
if [ "$CHOICE" = "w" -o "$CHOICE" = "W" ]
then
	if [ "$WIFISTATUS" = "1" ]
	then
		echo "0" > $WIFINIC/device/rfkill/rfkill0/state
	else
		echo "1" > $WIFINIC/device/rfkill/rfkill0/state
	fi
fi

# Toggle Bluetooth State
if [ "$CHOICE" = "b" -o "$CHOICE" = "B" ]
then
	if [ "$BTSTATUS" = "enabled" ]
	then
		echo "disabled" > /proc/acpi/ibm/bluetooth
	else
		echo "enabled" > /proc/acpi/ibm/bluetooth
	fi
fi


done

---- End /etc/acpi/thinkpad-toggle_wireless.sh ----




-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (990, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.29 (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1) (ignored: LC_ALL set to en_US)
Shell: /bin/sh linked to /bin/bash

Versions of packages acpi-support depends on:
ii  acpi-support-base             0.121-1    scripts for handling base ACPI eve
ii  acpid                         1.0.10-1   Utilities for using ACPI power man
ii  dmidecode                     2.9-1      Dump Desktop Management Interface 
ii  finger                        0.17-12    user information lookup program
ii  hdparm                        9.12-2     tune hard disk parameters for high
ii  laptop-detect                 0.13.7     attempt to detect a laptop
ii  libc6                         2.9-9      GNU C Library: Shared libraries
ii  lsb-base                      3.2-22     Linux Standard Base 3.2 init scrip
ii  powermgmt-base                1.30+nmu1  Common utils and configs for power
ii  vbetool                       1.1-2      run real-mode video BIOS code to a
ii  x11-xserver-utils             7.4+2      X server utilities

Versions of packages acpi-support recommends:
ii  dbus         1.2.12-1                    simple interprocess messaging syst
ii  hal          0.5.12~git20090406.46dc48-2 Hardware Abstraction Layer
ii  nvclock      0.8b4-1                     Allows you to overclock your nVidi
ii  pm-utils     1.2.5-2                     utilities and scripts for power ma
ii  radeontool   1.5-5                       utility to control ATI Radeon back
ii  toshset      1.74-3                      Access much of the Toshiba laptop 

Versions of packages acpi-support suggests:
ii  laptop-mode-tools             1.48-1     Scripts to spin down hard drive an

-- no debconf information





More information about the Pkg-acpi-devel mailing list