You are not logged in.
Pages: 1
Hi, I've made a little script for myself (well not only for myself) for switching between states of bluetooth and wifi. weird thing is, when I run it from the command line, it works just fine. when I call it via acpi it cycles only two stages back and forth. can anyone please point out where I am going wrong?
my /etc/acpi/events/thinkpad.conf
event=ibm/hotkey HKEY 00000080 00001005
action=/usr/local/bin/rfmy script /usr/local/bin/rf
#!/bin/ksh
# created by sDoky
#
# tested only on Lenovo R400
#
# the author is not responsible for any damage made by this script
#
# make sure you have the SUID flag turned on for rfkill and ifconfig
# or run this script as root. SUID flag is possibly dangerous, so be careful.
#
# to set suid flag run these two commands
#
# sudo chmod a+s $(which rfkill)
# sudo chmod a+s $(which ifconfig)
#
# released under GNU Free Documentation License 1.2
wlaniface="wlan0"
list=$(rfkill list)
bluetoothsoft=$(echo "$list" | sed -n '2p' | awk '{ print $3 }')
bluetoothhard=$(echo "$list" | sed -n '3p' | awk '{ print $3 }')
wifisoft=$(echo "$list" | sed -n '5p' | awk '{ print $3 }')
wifihard=$(echo "$list" | sed -n '6p' | awk '{ print $3 }')
#notify-send "$bluetoothsoft $wifisoft"
if [ $bluetoothsoft = "no" ]; then
bs=0
else bs=1
fi
if [ $bluetoothhard = "no" ]; then
bh=0
else bh=1
fi
if [ $wifisoft = "no" ]; then
ws=0
else ws=1
fi
if [ $wifihard = "no" ]; then
wh=0
else wh=1
fi
if [ $wh -eq 1 -a $bh -eq 1 ]; then
state=0
fi
if [ $ws -eq 1 -a $bs -eq 1 ]; then
state=1
# both down
fi
if [ $ws -eq 1 -a $bs -eq 0 ]; then
state=2
# wifi down, bt up
fi
if [ $ws -eq 0 -a $bs -eq 1 ]; then
state=3
# wifi up, bt down
fi
if [ $ws -eq 0 -a $bs -eq 0 ]; then
state=4
# both up
fi
case $state in
0) #notify-send "RFKILL switch off";;
;;
1)
rfkill unblock 0
rfkill block 1
#notify-send "turning bt on"
;;
2)
rfkill unblock 1
rfkill block 0
ifconfig $wlaniface up
#notify-send "turning wifi on, turning bt off"
;;
3)
rfkill unblock 0
rfkill unblock 1
ifconfig $wlaniface up
#notify-send "turning both on"
;;
4)
rfkill block 0
rfkill block 1
#notify-send "turning both off"
;;
esacBTW: I used to use ordinary echo, but acpi didn't print out these messages, so I had to use the notify-send
Linux!
Offline
Pages: 1