I had to make changes because I didn't realize that rfkill could change.  Here 
is the updated script:

#!/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 -a -d $DEVICE/device/rfkill ]
then
        WIFINIC="$DEVICE"
fi
done

# Find Wi-Fi state
for FINDSTATE in $WIFINIC/device/rfkill/*
do
echo $FINDSTATE
if [ -f $FINDSTATE/state ]
then
        STATE="$FINDSTATE"
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 $STATE/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" > $STATE/state
        else
                echo "1" > $STATE/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
exit



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to