Page 1 of 1

wireless adaptor on/off hotkeys?

Posted: Wed Mar 25, 2009 10:26 pm
by TheRedFox
is this possible in linux, using xbindkeys or something? I have recently been getting a lot of my hotkeys working (audio keys, screen off key, back/forward keys, trackpoint scrolling. (I'd be happy to give people information about these if they want). I can't figure out a command to toggle on/off rather than doing one or the other. is there one?
any ideas?

Re: wireless adaptor on/off hotkeys?

Posted: Tue Mar 31, 2009 9:23 pm
by gongo2k1
Using Lenny on my X41, the hotkeys just work, no fiddling required.
Take a look at acpid if you want to intercept the keystrokes since they don't generate real keyboard events, they are sent as acpi messages instead. You'll just a rule file with a regex to catch the events and then a shell script to execute that passes the event as a parameter to the script. I had to do this with my old Asus Z71v laptop a couple years ago.

Re: wireless adaptor on/off hotkeys?

Posted: Tue Mar 31, 2009 9:30 pm
by TheRedFox
well, I also don't know a command that toggles eth1 on/off. I know how to turn it on, and how to turn it off, but I don't know what command will do one if the other is true.

Re: wireless adaptor on/off hotkeys?

Posted: Tue Mar 31, 2009 9:39 pm
by gongo2k1
man ifup
man ifdown
man ifconfig
man grep

and then find yourself a nice online tutorial for bash scripting.
good luck! :thumbs-UP:

Re: wireless adaptor on/off hotkeys?

Posted: Tue Mar 31, 2009 9:42 pm
by TheRedFox
i'll see what I can do, I guess...

Re: wireless adaptor on/off hotkeys?

Posted: Tue Mar 31, 2009 10:09 pm
by TheRedFox
does anybody happen to know if the wireless adaptor state is contained in a file?

Re: wireless adaptor on/off hotkeys?

Posted: Thu Apr 02, 2009 4:03 am
by bluesceada
For the wireless one, I would just use the killswitch at the front bottom of the laptop.

To get hotkeys working, look with acpi_listen and modify the scripts in /etc/acpi/events/*

For example (pressing Fn+F8 on my X61s when doing acpi_listen):

Code: Select all

$ > acpi_listen
ibm/hotkey HKEY 00000080 00001008
^C
$ > grep "HKEY 00000080 00001008" /etc/acpi/events/*
/etc/acpi/events/lenovo-touchpad:event=ibm/hotkey HKEY 00000080 00001008
Means you have to change the "action=" in /etc/acpi/events/lenovo-touchpad to the shellscript or binary you want!
If you can not find a file in the events directory with grep, it means you can create yourself one, just look at the other files in the events directory how to do that!

Have fun and good luck!


WLAN Status can be found here (for iwlagn, for iwl4965 or iwl3965 or whatever, just look for that in /sys/bus/pci/drivers/):

/sys/bus/pci/drivers/iwlagn/0000\:03\:00.0/enable

echoing a zero to it will disable it... echoing a one again will enable it

Re: wireless adaptor on/off hotkeys?

Posted: Fri Apr 03, 2009 12:05 am
by TheRedFox
aha... plans are slowly coming to me... very slowly. then again it is midnight:04 where I am, so i'm not exactly at my fastest

Re: wireless adaptor on/off hotkeys?

Posted: Fri Apr 03, 2009 12:54 am
by TheRedFox
so when I was first testing in the python interperator things were going smoothly. the file had 1 written into it and I could turn it to zero by running the command ifconfig eth1 up, however after writing a script that checked to see what the value of the file was, and then ran an ifconfig command that should turn it to the opposite state depending on what it was. no errors happened, but the wireless card didn't turn off. later i found out that the file was stuck on zero regardless of the state of the card.
AAARGH!!!!

Re: wireless adaptor on/off hotkeys?

Posted: Fri Apr 03, 2009 2:06 am
by TheRedFox
the actual file doesn't work well so I created my own!!!! MWAHAHAHAHA!!!!
I was able to think about this connundrum more programatically, and now it works.
copy this info into a file and chmod it +x.
the comments explain the necessary user additions.
the official name of the program is "witrog.py" incase anyone cares.

Code: Select all

#!/usr/bin/python
#second try at wifi command
######################################################################################
#you'll need to somehow have the file $HOME/wistate have whatever state your wireless#
#card is normally in when your computer starts up written to it at start up. my      #
#recommendation would be adding a line "echo 1 > $HOME/wistate" to your rc.local     #
#1 is equivalent to on, 0 is equivalent to off                                       #
######################################################################################

#$HOME doesn't register as anything in python, so you'll have to input the full /home/user
#here; this is the file this program will be reading for wireless state. you can make it hidden by 
#naming it .wistate instead of just wistate...
FILE="$HOME/wistate"
#in both of these lines, here, replace eth1 with whatever your wireless adapter is called
spool="ifconfig eth1 up"
pants="ifconfig eth1 down"

import os
f=open(FILE, "r")
fridge=f.read()
f.close()

if fridge=="1\n":
    os.system(pants)
    f=open(FILE, "w")
    f.write("0\n")
    f.close()
elif fridge=="0\n":
    os.system(spool)
    f=open(FILE, "w")
    f.write("1\n")
    f.close()
else:
    print "failure"
    #this command is to make this script automatically calibrate itself after a few runs
    #if all else fails:
    f=open(FILE, "w")
    f.write("0\n")
    f.close()

Re: wireless adaptor on/off hotkeys?

Posted: Sat Apr 18, 2009 8:22 pm
by bluesceada
Normally you shouldn't need that and using the sysfs files should be alright.
And are you sure that you can turn wireless off using ifconfig commands? I would say that isn't really possible... they just turn the network connection off, not the device...

And are you also sure, that eth1 is your wireless device and not your ethernet network adapter? They are in most distros called wlan0 wlan1 etc. nowadays.

For the intel devices my description is the recommended way of really turning them off (see here: http://www.lesswatts.org/tips/wireless.php ). For an atheros card it might be different though.

Re: wireless adaptor on/off hotkeys?

Posted: Sat Apr 18, 2009 8:41 pm
by TheRedFox
well eth1 was definately my device at that time. since my motherboard update, for some reason, it changed to eth0. whatever. It probably doesn't turn the actual connection off, but it does turn the status light off...

Re: wireless adaptor on/off hotkeys?

Posted: Sun Apr 19, 2009 5:19 am
by bluesceada
You are sure? And what would your wired network device be then?

But ok, if ifconfig turns the wlan status lights off, it should be ok.

Re: wireless adaptor on/off hotkeys?

Posted: Mon Apr 20, 2009 8:29 pm
by TheRedFox
yeah, I am sure, I've used it more than a few times. wired network is atm eth1, used to be eth0.

Re: wireless adaptor on/off hotkeys?

Posted: Thu Apr 23, 2009 4:58 am
by bluesceada
Eh yeah... I thought the topic was about the wireless adapter :roll:

Re: wireless adaptor on/off hotkeys?

Posted: Wed Apr 29, 2009 10:26 pm
by TheRedFox
it is about the wireless adaptor, but more about a script to toggle it.
also on my new laptop I was pretentious and put my wistate file in /usr/share/witrog/, and the script of course in /usr/bin, but that's for convenience, not to feel cool