Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Tutorials & Tips
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Ubuntu 9.10 is out!!!

When downloading Ubuntu 9.10 please consider using bittorrent to get your copy of Ubuntu.

The Ubuntu Developers Summit for Lucid Lynx will be held the week of 16-Nov-2009 till 20-Nov-2009 in Dallas, TX USA. Visit the the Ubuntu wiki for more information about UDS and how to participate remotely.

Tutorials & Tips
The place to find Ubuntu related Tips & Tricks.

 
Thread Tools Display Modes
Old November 21st, 2006   #1
elektronaut
Gee! These Aren't Roasted!
 
Join Date: Jun 2005
Location: /world/OldEurope
Beans: 159
Ubuntu 9.04 Jaunty Jackalope
Send a message via ICQ to elektronaut Send a message via Skype™ to elektronaut
HowTo: Wireless Radio Software Switch

[EDIT:] This thread was renamed as the problem is solved and now it's kind of a HowTo.
--------------------------------------------------------------------------------------

Hi,

I want to enable and disable my wireless card using the wlan switch. So I wrote a script that needs root privileges as it needs write access to a sysfs file. For those interested, here's the script:
Code:
#!/bin/bash
# this is the script /usr/local/bin/3945-toggle-state

STATE=$(cat /sys/bus/pci/drivers/ipw3945/*/rf_kill)

if [ "$STATE" == 1 ]
then
        echo 0 > /sys/bus/pci/drivers/ipw3945/*/rf_kill
else
        echo 1 > /sys/bus/pci/drivers/ipw3945/*/rf_kill
fi

exit 0
In order to avoid entering the sudo password each time, I added this to /etc/sudoers (Be careful and use visudo, otherwise you could get into trouble):
Code:
me ALL=NOPASSWD: /usr/local/bin/3945-toggle-state
So far, so good: This works if I call the script in the terminal. But as I wanted to attach it to the wlan switch, I found out it's keycode using 'tail -f /var/log/messages' and set it to another value 'sudo setkeycodes e055 149'. Then I added an entry in the configuration file for xbindkeys, xbindkeysrc.scm:
Code:
(xbindkey '("m:0x0" "c:149") "sudo /usr/local/bin/3945-toggle-state")
But it doesn't work. If I replace the call to the script with some other command, gaim for example, it works: The program is called upon activation of the switch. But not my script. Why is this so?

[EDIT:] I guess I just stared too long at the screen... There was an error in the path. I corrected this now, so you can use it as a HowTo Everything is working now

Last edited by elektronaut; December 6th, 2006 at 07:51 AM..
elektronaut is offline   Reply With Quote
Old December 3rd, 2006   #2
elektronaut
Gee! These Aren't Roasted!
 
Join Date: Jun 2005
Location: /world/OldEurope
Beans: 159
Ubuntu 9.04 Jaunty Jackalope
Send a message via ICQ to elektronaut Send a message via Skype™ to elektronaut
Re: HowTo: Wireless Radio Software Switch

One thing still puzzles me: I have this in /etc/rc.local:
Code:
setkeycodes e055 213
and this in ~/.xbindkeysrc.scm:
Code:
(xbindkey '("m:0x0" "c:118") "sudo /usr/local/bin/3945-toggle-state")
and it works though the keycodes are different. I found out about the keycode using 'xev'. How does it come that the keycode is set to 118 and not 213?

Last edited by John.Michael.Kane; December 3rd, 2006 at 10:00 AM..
elektronaut is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:47 AM.


vBulletin ©2000 - 2009, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. lingonberry