wireless adaptor on/off hotkeys?

Solaris, RedHat, FreeBSD and the like
Post Reply
Message
Author
TheRedFox
Sophomore Member
Posts: 212
Joined: Sat Jan 17, 2009 2:27 am
Location: MN

wireless adaptor on/off hotkeys?

#1 Post by TheRedFox » Wed Mar 25, 2009 10:26 pm

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?
Frankenpad X31.5 (X31 casing, X32 motherboard) 1.8ghz Pentium M processor, 1gb RAM,
60gb HDD dual booting Arch GNU/Linux && Windows XP

gongo2k1
Sophomore Member
Posts: 200
Joined: Mon Jun 30, 2008 10:25 pm

Re: wireless adaptor on/off hotkeys?

#2 Post by gongo2k1 » Tue Mar 31, 2009 9:23 pm

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.

TheRedFox
Sophomore Member
Posts: 212
Joined: Sat Jan 17, 2009 2:27 am
Location: MN

Re: wireless adaptor on/off hotkeys?

#3 Post by TheRedFox » Tue Mar 31, 2009 9:30 pm

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.
Frankenpad X31.5 (X31 casing, X32 motherboard) 1.8ghz Pentium M processor, 1gb RAM,
60gb HDD dual booting Arch GNU/Linux && Windows XP

gongo2k1
Sophomore Member
Posts: 200
Joined: Mon Jun 30, 2008 10:25 pm

Re: wireless adaptor on/off hotkeys?

#4 Post by gongo2k1 » Tue Mar 31, 2009 9:39 pm

man ifup
man ifdown
man ifconfig
man grep

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

TheRedFox
Sophomore Member
Posts: 212
Joined: Sat Jan 17, 2009 2:27 am
Location: MN

Re: wireless adaptor on/off hotkeys?

#5 Post by TheRedFox » Tue Mar 31, 2009 9:42 pm

i'll see what I can do, I guess...
Frankenpad X31.5 (X31 casing, X32 motherboard) 1.8ghz Pentium M processor, 1gb RAM,
60gb HDD dual booting Arch GNU/Linux && Windows XP

TheRedFox
Sophomore Member
Posts: 212
Joined: Sat Jan 17, 2009 2:27 am
Location: MN

Re: wireless adaptor on/off hotkeys?

#6 Post by TheRedFox » Tue Mar 31, 2009 10:09 pm

does anybody happen to know if the wireless adaptor state is contained in a file?
Frankenpad X31.5 (X31 casing, X32 motherboard) 1.8ghz Pentium M processor, 1gb RAM,
60gb HDD dual booting Arch GNU/Linux && Windows XP

bluesceada
Freshman Member
Posts: 82
Joined: Thu Mar 05, 2009 7:20 am
Location: Karlsruhe, Germany
Contact:

Re: wireless adaptor on/off hotkeys?

#7 Post by bluesceada » Thu Apr 02, 2009 4:03 am

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

TheRedFox
Sophomore Member
Posts: 212
Joined: Sat Jan 17, 2009 2:27 am
Location: MN

Re: wireless adaptor on/off hotkeys?

#8 Post by TheRedFox » Fri Apr 03, 2009 12:05 am

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
Frankenpad X31.5 (X31 casing, X32 motherboard) 1.8ghz Pentium M processor, 1gb RAM,
60gb HDD dual booting Arch GNU/Linux && Windows XP

TheRedFox
Sophomore Member
Posts: 212
Joined: Sat Jan 17, 2009 2:27 am
Location: MN

Re: wireless adaptor on/off hotkeys?

#9 Post by TheRedFox » Fri Apr 03, 2009 12:54 am

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!!!!
Frankenpad X31.5 (X31 casing, X32 motherboard) 1.8ghz Pentium M processor, 1gb RAM,
60gb HDD dual booting Arch GNU/Linux && Windows XP

TheRedFox
Sophomore Member
Posts: 212
Joined: Sat Jan 17, 2009 2:27 am
Location: MN

Re: wireless adaptor on/off hotkeys?

#10 Post by TheRedFox » Fri Apr 03, 2009 2:06 am

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()
Frankenpad X31.5 (X31 casing, X32 motherboard) 1.8ghz Pentium M processor, 1gb RAM,
60gb HDD dual booting Arch GNU/Linux && Windows XP

bluesceada
Freshman Member
Posts: 82
Joined: Thu Mar 05, 2009 7:20 am
Location: Karlsruhe, Germany
Contact:

Re: wireless adaptor on/off hotkeys?

#11 Post by bluesceada » Sat Apr 18, 2009 8:22 pm

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.

TheRedFox
Sophomore Member
Posts: 212
Joined: Sat Jan 17, 2009 2:27 am
Location: MN

Re: wireless adaptor on/off hotkeys?

#12 Post by TheRedFox » Sat Apr 18, 2009 8:41 pm

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...
Frankenpad X31.5 (X31 casing, X32 motherboard) 1.8ghz Pentium M processor, 1gb RAM,
60gb HDD dual booting Arch GNU/Linux && Windows XP

bluesceada
Freshman Member
Posts: 82
Joined: Thu Mar 05, 2009 7:20 am
Location: Karlsruhe, Germany
Contact:

Re: wireless adaptor on/off hotkeys?

#13 Post by bluesceada » Sun Apr 19, 2009 5:19 am

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.

TheRedFox
Sophomore Member
Posts: 212
Joined: Sat Jan 17, 2009 2:27 am
Location: MN

Re: wireless adaptor on/off hotkeys?

#14 Post by TheRedFox » Mon Apr 20, 2009 8:29 pm

yeah, I am sure, I've used it more than a few times. wired network is atm eth1, used to be eth0.
Frankenpad X31.5 (X31 casing, X32 motherboard) 1.8ghz Pentium M processor, 1gb RAM,
60gb HDD dual booting Arch GNU/Linux && Windows XP

bluesceada
Freshman Member
Posts: 82
Joined: Thu Mar 05, 2009 7:20 am
Location: Karlsruhe, Germany
Contact:

Re: wireless adaptor on/off hotkeys?

#15 Post by bluesceada » Thu Apr 23, 2009 4:58 am

Eh yeah... I thought the topic was about the wireless adapter :roll:

TheRedFox
Sophomore Member
Posts: 212
Joined: Sat Jan 17, 2009 2:27 am
Location: MN

Re: wireless adaptor on/off hotkeys?

#16 Post by TheRedFox » Wed Apr 29, 2009 10:26 pm

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
Frankenpad X31.5 (X31 casing, X32 motherboard) 1.8ghz Pentium M processor, 1gb RAM,
60gb HDD dual booting Arch GNU/Linux && Windows XP

Post Reply
  • Similar Topics
    Replies
    Views
    Last post

Return to “Linux Questions”

Who is online

Users browsing this forum: No registered users and 1 guest