Active Topics

 



Notices


Reply
Thread Tools
Posts: 323 | Thanked: 32 times | Joined on Jun 2009 @ Southern Oregon Coast
#1
Not sure if this is the protocal for a request so sorry (mods) if it isn't.

I have turned into a heavy user of the Advanced Power utility and find myself in a pattern of use that I wonder if it would be possible to automate and label?

The pattern is: in Device Mode;

1 set to Performance option

2 use Firefox Mobile and close when done

3 set to On Demand or Power Save mode

4 not use the NIT til needed again...

So, could this process be automated in a piece of code?

If so, could it be done with an implementation of a timer? So if the NIT is not used after say 10 minutes (track usage of Firefox mobile) it would resort to a kind of "Time Out" setting in step 3?

I have no clue what I am asking here so please go easy if this is a ridiculous request.

Thx
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#2
The only complication I can see.. is the 10 minute timer. I'm not sure there's a way in a shell script or other code to determine when the last time you did anything with Firefox Mobile was....

The rest of it looks fairly simple.. I'll need to look at the "Advanced Power" utility to be sure, but in theory yes: setting a device to performance mode, launching an app and waiting for app to close, setting device to sleep mode... should all be fairly trivial I think.. I'll mess with my N810 later and see what I come up with.

ETA: Not sure if it could be implemented directly into Advanced Power Utility though.. was that a community app? Or a Nokia one?
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!
 
Posts: 323 | Thanked: 32 times | Joined on Jun 2009 @ Southern Oregon Coast
#3
sweet!

if you are to find that it is fairly simple, is this the kind of project that would be good as a learning tool for me to understand the coding process.

I know that you guys are much more into the "teaching a man to fish" idea than feeding him...you know where I am going with this!
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#4
Originally Posted by coosbaytv View Post
sweet!

if you are to find that it is fairly simple, is this the kind of project that would be good as a learning tool for me to understand the coding process.

I know that you guys are much more into the "teaching a man to fish" idea than feeding him...you know where I am going with this!
depending what it takes sure.. again the two things unknown to me at this point is:

1) The timer
2) Integration with this "AP" utility.
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#5
Ok so, the most basic form that you're after is:

Code:
echo 'echo performance >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor' | sudo gainroot
fennec
echo 'echo ondemand >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor' | sudo gainroot
Save that to something like "run_firefox.sh" and move it to /usr/bin. Then chmod +x /usr/bin/run_firefox.sh.

That's your basic: Set CPU to performance, run firefox, set CPU to ondemand. It doesn't do the timer/timeout thing (I don't know how you'd know whether firefox is active or not) and obviously there's no GUI for it.

You can use something like Personal Menu to create a shortcut to it, or create your own .desktop file in /usr/share/applications/ somewhere to show up in the normal menu.

Advanced Power Manager does provide a src package.. so you *could* modify the sources of that to include this somewhere in there.. but it'd be better to get the maintainer of that to do it than to create a fork that would have to be released separately.
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!
 
Posts: 323 | Thanked: 32 times | Joined on Jun 2009 @ Southern Oregon Coast
#6
@fatalsaint, WOW!

I wasn't expecting something that quick... now that that is out of the way, I need to slow things down just a bit.

FYI, the timer is by no means a deal breaker.

Just to make sure I don't brick or crash my device, I need a little more info between steps as I have only literally done a copy and paste when it comes to using the terminal. (I pasted EXACTLY what I was told).
Now I need to cautiously go beyond that.

So...when you say "Save that to something like "run_firefox.sh" and move it to /usr/bin. Then chmod +x /usr/bin/run_firefox.sh." This is already beyond my knowledge base.

And thanks again for doing this.
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#7
Code:
sudo gainroot
cat > /usr/bin/run_firefox.sh << EOF
echo 'echo performance >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor' | sudo gainroot
fennec
echo 'echo ondemand >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor' | sudo gainroot
EOF
chmod +x /usr/bin/run_firefox.sh


It's just a series of commands. 3 to be exact. You save it to a file, you can use a text editor or whatever, call the file whatever you want. Once you have the file, move it using whatever method you want (midnight commander, mv) as root to /usr/bin.

Then you set it to executable with "chmod +x /usr/bin/file". (replace "file" with your name..)

You would then run it in a terminal (as user) with "file" or "run_firefox.sh" or whatever you named it.

NOTE: Don't copy/paste the above into a file.. that's meant to be copy/pasted into the terminal and it'll create the file with the content for you. If you copy/paste the above you'll have a new command "run_firefox.sh" that does it. If you do it by hand.. use the 3 commands in the previous post and save those to a file.
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!

Last edited by fatalsaint; 2010-02-10 at 02:02.
 
Posts: 323 | Thanked: 32 times | Joined on Jun 2009 @ Southern Oregon Coast
#8
OK, will work on that after bit...
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#9
If I get some extra time I can wrap it into a deb or something for you to install.. but as you said earlier this gives you a perfect thing to build and get into coding.

You have 3 separate commands:
echo 'echo performance >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor' | sudo gainroot

That one sets the CPU to performance mode. It passes it to sudo gainroot because it requires root access, but fennec won't run unless it's run as user.

fennec

That one launches Fennec/Firefox. It will stay locked there until firefox is closed.. then it will move on.

echo 'echo ondemand >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor' | sudo gainroot

Sets the CPU back to ondemand.. you can do "powersave" or whatever instead of "ondemand" as well. Like the above it passes it through to sudo gainroot.

The way shell scripting works is you just put your commands into a "script".. which is just a text file. Commonly these end with a ".sh" extension to identify them as shell scripts, but they don't have to, any text file with any name that contains commands can be a shell script. It will then run the commands in order.

Once you have your script, you make it executable. In linux that means to run the command:
chmod +x <file>

With the full path to wherever your file is.

Now that you have the basic structure, you can do anything you want with it.. it's possible to write another "dock" app that sits in the top by the Advanced Power icon that you could just "click" and it runs those three commands for you.. or you can write a pyQt4 wrapper for it or possibly even a desktop widget (applet).. any and all of these are relatively simple to do and this gives you an excuse to learn it .
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!

Last edited by fatalsaint; 2010-02-10 at 02:56.
 
Reply


 
Forum Jump


All times are GMT. The time now is 03:35.