View Single Post
MohammadAG's Avatar
Posts: 2,473 | Thanked: 12,265 times | Joined on Oct 2009 @ Jerusalem, PS/IL
#51
Originally Posted by gionni88 View Post
I was thinking about a QProcess that does this:
Code:
echo 'echo 3 > /sys/blahblahblah/region' | root
and calling it through a menu action, but still I need to know that doing that works,
That means you'd have to depend on rootsh, which isn't really necessary.

Code:
#!/bin/sh

sysfile=/sys/class/i2c-adapter/i2c-2/2-0063/region

if [ "$1" = "japan" ]
    then
        echo 3 > $sysfile
fi

if [ "$1" = "europe" ]
    then
        echo 2 > $sysfile
fi

exit 0
I also suggest that you store region, instead of echoing 2 back into it, my region seems to be 4.
Have a look at keyboard-leds, it uses system(), though you should be easily able to translate that to QProcess.
Call the script as sudo, not the whole app, keyboard-leds was kind of an exception and a proof of concept, rather than an app like this

http://gitorious.org/keyboard-leds/k...s/trees/master

Check the .sh file and the .sudoers file, remember to call update-sudoers (and exit 0 after that, otherwise, it sometimes errors out on my device) in postinst and postrm.
 

The Following 2 Users Say Thank You to MohammadAG For This Useful Post: