Active Topics

 


Reply
Thread Tools
Posts: 152 | Thanked: 41 times | Joined on Dec 2009 @ Sydney
#91
Originally Posted by DaveQB View Post
Oh good one.

Well what I did was 3 things:

1. Become root, run visudo. In that text file [be careful] add line:
user ALL = NOPASSWD: /usr/local/bin/118
ie type
O
user ALL = NOPASSWD: /usr/local/bin/118
[ESC]
:x

2. Make a file "/usr/local/bin/118"
with contents:
Code:
#!/bin/sh
/bin/echo 118 > /sys/class/i2c-adapter/i2c-2/2-0063/power_level
exit 0
Then type:
Code:
chmod 755 /usr/local/bin/118
3. Add file:
/usr/share/applications/hildon/118.desktop
With contents:

Code:
[Desktop Entry]
Version=0.1
Type=Application
Name=118
Exec= /usr/bin/sudo /usr/local/bin/118
Icon=
X-Windows-Icon=
X-HildonDesk-ShowInToolbar=false
X-Osso-Type=application/x-executable
And now you have an app called 118 that does what you want.
I am not an expert on hildon *.desktop files and running this command waits for some sort of X feedback, so you need to multi-task out and it disappears.

Please someone tidy up that part of it.

I have put those two files you create in that in a tarball you get download onto the N900 directly.

So run this as root:

Code:
wget http://www.dward.us/software/118.tar
tar xf 118.tar
Now run ls and they will both be there, so now just run:

Code:
mv 118 /usr/local/bin/
mv 118.desktop /usr/share/applications/hildon/
HTH

Last edited by DaveQB; 2010-01-05 at 23:21. Reason: Typo, again
 
Posts: 63 | Thanked: 23 times | Joined on Dec 2008
#92
I was trying to get the exact same thing running and it's great that someone got it working! =)

Anyway, I hit a bump trying to follow your steps:
Nokia-N900-42-11:~# visudo
visudo: no editor found (editor path = /bin/vi)

Any clue? I'm using an ssh connection and logged in as root.
 
Posts: 152 | Thanked: 41 times | Joined on Dec 2009 @ Sydney
#93
Originally Posted by ssjtoma View Post
I was trying to get the exact same thing running and it's great that someone got it working! =)

Anyway, I hit a bump trying to follow your steps:
Nokia-N900-42-11:~# visudo
visudo: no editor found (editor path = /bin/vi)

Any clue? I'm using an ssh connection and logged in as root.
Oh ok, I thought that was just my N900.

Just link it to vim, you do have vim installed?

Code:
ln -s /usr/bin/vim /bin/vi
 

The Following 2 Users Say Thank You to DaveQB For This Useful Post:
Posts: 63 | Thanked: 23 times | Joined on Dec 2008
#94
Originally Posted by DaveQB View Post
Oh ok, I thought that was just my N900.

Just link it to vim, you do have vim installed?

Code:
ln -s /usr/bin/vim /bin/vi
No, but I'm installing it right now =)
 
Posts: 63 | Thanked: 23 times | Joined on Dec 2008
#95
Nice. Works like a charm. I renamed it though to RadioHACK =)
 
Posts: 152 | Thanked: 41 times | Joined on Dec 2009 @ Sydney
#96
Originally Posted by ssjtoma View Post
Nice. Works like a charm. I renamed it though to RadioHACK =)
Cool. There was a typo in my code with the untaring. I have edited and fixed that, sorry.

Now to make the GUI side effect much better.
I am installed the Maemo 5 SDK, so maybe I will make this a whole lot better and add a dialog box to say the command was successful.
 
Posts: 63 | Thanked: 23 times | Joined on Dec 2008
#97
Haha nice. Don't forget to add the permission setting steps to your guide with the tar ball!

chmod 755 /usr/local/bin/118

 
Posts: 152 | Thanked: 41 times | Joined on Dec 2009 @ Sydney
#98
Originally Posted by ssjtoma View Post
Haha nice. Don't forget to add the permission setting steps to your guide with the tar ball!

chmod 755 /usr/local/bin/118

That is the idea of the tarball; tar preserves unix perms, that's why I used that method.
 
debernardis's Avatar
Posts: 2,142 | Thanked: 2,054 times | Joined on Dec 2006 @ Sicily
#99
I wrote to Pekka Ronkko, author of the simple-fmtx widget, to enclose the hack in the next version of his package. Best solution imho.
__________________
Ernesto de Bernardis

 

The Following 4 Users Say Thank You to debernardis For This Useful Post:
slavikko's Avatar
Posts: 20 | Thanked: 15 times | Joined on Nov 2009 @ Turku, Finland
#100
Wrote the following quick & dirty script to use with desktop-cmd-exec

Create a file with the following code to /usr/local/bin/toggleradio.sh

Code:
#!/bin/bash
fmtx_client|grep disabled > /dev/null
if [ $? -eq 0 ]; then
   fmtx_client -p 1 > /dev/null
   fmtx_client -f 106900 > /dev/null
   echo 118 > /sys/class/i2c-adapter/i2c-2/2-0063/power_level
   echo "RF Enabled @106.90 with power `cat /sys/class/i2c-adapter/i2c-2/2-0063/power_level`"
else
   fmtx_client -p 0
   echo "RF Disabled"
fi
exit 0
chmod 755 /usr/local/bin/toggleradio.sh
add
Code:
user ALL = NOPASSWD: /usr/local/bin/toggleradio.sh
to /etc/sudoers

This will enable the rf transmitter if it's disabled and raise the power and disabled it if it's enabled. Configure desktop-cmd-exec to run it on click. The command line to insert to desktop-cmd-exec is 'sudo /usr/local/bin/toggleradio.sh'

Note, needs bash which you can get by
Code:
apt-get install bash
NOTE: there's seemingly a bug in the desktop-cmd-exec right now which causes it to run the script when you return to the desktop even though it's set to run on-click. I contacted the dev and hope that it'll be sorted out soon.

Made a new version of the script that's not dependent on bash & has some optional parameters to set the xmit power / freq
Code:
#!/bin/sh
#N900 FM transmitter toggler

#Establishing funtions
enableFM () {
   fmtx_client -p1 > /dev/null
   if [ $freq ]; then
        fmtx_client -f$freq > /dev/null
   fi
   echo $power > /sys/class/i2c-adapter/i2c-2/2-0063/power_level
   freq=`fmtx_client |grep frequency=|awk '{print int(substr($1,11))/1000};'`
   echo "RF Enabled @"$freq" with power `cat /sys/class/i2c-adapter/i2c-2/2-0063/power_level`"
   return 0
}

disableFM () {
   fmtx_client -p 0 > /dev/null
   echo "RF Disabled"
   return 0
}

usage () {
        echo "Usage:"
        echo " By default the script sets the power to 118 and does not mess with your default frequency, if you just run it."
        echo " Optional parameter one let's you define the transmission power manually"
        echo " Optional parameter two let's you define the frequency manually (eg. 106900 for 106.9)"
 exit 0
}



#Very simple command line parsing
case "$1" in
        [0-9]* )        power=$1;;
        [A-Za-z\-]* )   usage;;
        * )             power=118;;
esac
case "$2" in
        [0-9]* )        freq=$2;;
        * )
esac

fmtx_client|grep disabled > /dev/null
if [ $? = 0 ]; then
  enableFM
else
  disableFM
fi
exit 0

Last edited by slavikko; 2010-01-04 at 14:20. Reason: and again a new version with better command line parsing.
 

The Following 8 Users Say Thank You to slavikko For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 02:24.