Reply
Thread Tools
Posts: 479 | Thanked: 1,284 times | Joined on Jan 2012 @ Enschede, The Netherlands
#1
Here's a little Python script which will turn the notification led of the N9 into a simple CPU usage monitor. The higher the current CPU usage, the brighter the led. Simple as that.

Usage:
  • Extract the attached zip somewhere, e.g. your home dir. (forum won't allow .py files )
  • Open a terminal.
  • Switch to root (devel-su) as the script needs root to control the led.
  • run: "python cpumonled.py"
  • ...
  • Profit!

Ctrl+c aborts the script. You can also call it using "nohup python cpumonled.py". You can then close the terminal and the script will run in background. Use "killall python" later to kill it.

It works fine, and it uses very little CPU itself. Also, I reckon it uses very little energy as well, as the led is mostly dark.

But.. I'm looking for a way to make an indicator for actual power consumption. As such I would need to obtain the current... eh.. current, much like energy profiler and battery usage monitor. But I don't know where to get that data (let alone getting it using Python..) Anyone any pointers?

Also, it would be nice if the script runs without root. Is there a way to control the led as user?
Attached Files
File Type: zip cpumonled.zip (707 Bytes, 121 views)
 

The Following 3 Users Say Thank You to Fuzzillogic For This Useful Post:
coderus's Avatar
Posts: 6,436 | Thanked: 12,699 times | Joined on Nov 2011 @ Ängelholm, Sweden
#2
you need to package it to deb and incluge aegis manifest to be able to start executable as root from user.
also will be nice to start it as daemon from system init
__________________
Telegram | Openrepos | GitHub | Revolut donations
 

The Following User Says Thank You to coderus For This Useful Post:
Mikkosssss's Avatar
Posts: 645 | Thanked: 519 times | Joined on Apr 2012 @ Finland
#3
Nice! But I will wait for .deb file and background daemon if you are planning to do those.
__________________
────────────────────
Try:My N9 bootvideo
 
minipac's Avatar
Posts: 63 | Thanked: 19 times | Joined on May 2012
#4
can we change the color of led also ?
__________________
Nokia 9000, 9110i, 9210i, 9500, E90, N900, N8, E7, N9
 
coderus's Avatar
Posts: 6,436 | Thanked: 12,699 times | Joined on Nov 2011 @ Ängelholm, Sweden
#5
you can use colored highlight marker for that
led is white. it cant loght on different color
__________________
Telegram | Openrepos | GitHub | Revolut donations
 
Mikkosssss's Avatar
Posts: 645 | Thanked: 519 times | Joined on Apr 2012 @ Finland
#6
Also when CPU usage goes more than 90% or 95% LED should blink rapidly.
__________________
────────────────────
Try:My N9 bootvideo
 
Posts: 479 | Thanked: 1,284 times | Joined on Jan 2012 @ Enschede, The Netherlands
#7
Blinking is annoying, as higher CPU loads are common when starting apps, playing games, etc.

I'm not sure if it's worth the effort to create an installable app for this. It's more of a gimmick now and, as mentioned, the actual goal for me is to signal excessive power consumption, which can unexpectedly drain the battery. I've left Opera running in the background a few times, and depending on the site which was open, it can kill the battery in hours.

Also, currently my N9's idle consumption is higher than normal, so this script might drain more than I've expected, rendering it counterproductive..
 

The Following User Says Thank You to Fuzzillogic For This Useful Post:
Mikkosssss's Avatar
Posts: 645 | Thanked: 519 times | Joined on Apr 2012 @ Finland
#8
I have desktop icon that kills all apps that leave background like fennec, Cutetube and Opera.
Its now habit that I tap it before I lock my phone. :P
__________________
────────────────────
Try:My N9 bootvideo
 

The Following User Says Thank You to Mikkosssss For This Useful Post:
Mikkosssss's Avatar
Posts: 645 | Thanked: 519 times | Joined on Apr 2012 @ Finland
#9
Hmm made script that starts cpumonled (so I could start it from desktop icon) and it works fine, but cant kill it.

EDIT2: There was only other process (buttonmonitor) that I could not kill. (and thats good)


What is command to refresh led so it wont stay lit after I kill cpuledmon? Now I need to lock and open screen.

EDIT3: Not so fine killing still wont work.
I think problem is in my if command.

Code:
#!/bin/sh

if ps aux | grep '[p]ython cpumonled.py';
then
    killall python echo Killed
else
   nohup python /home/user/Asd/cpumonled.py echo Running
fi
__________________
────────────────────
Try:My N9 bootvideo

Last edited by Mikkosssss; 2013-08-22 at 18:23.
 
Posts: 479 | Thanked: 1,284 times | Joined on Jan 2012 @ Enschede, The Netherlands
#10
Better solution would be to use a pid/lock-file. I see some half-broken solutions out there in Python, none of which using the O_CLOEXEC parameter when creating the file...

I'll whip up something tomorrow.
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 11:28.