Notices


Reply
Thread Tools
Posts: 12 | Thanked: 28 times | Joined on Jan 2010
#1
Since i disabled system sounds, I often miss when the battery goes low. Unfortunately Nokia missed the opportunity to signal this with the notification LED. So here is a small hack, I may turn this into a proper daemon written in C someday, but thinking about it there is no much need for it. Note that it gets extremely rare waken up (only when battery gets low or you plug in the charger) so, by itself it needs very minimal resources, blinking the LED does not consume much power either just in case you thik about that.

I posting this here, maybe someone has use for it or may even package it (or implement it in C). There is currently one small problem that it leaves a stale process around when one stops it (busybox problem?) But since it should be started at startup and never be stopped this doesn't hurt much. Anyways If anyone fixes this, please notify me.

You need to hack some upstart and/or init.d scripts to start it on boot, I don't post these here and leave that as exercise to the reader. I've also defined my own 'PatternBatteryLow' in /etc/mce/mce.ini, if you are too lazy to define your own, you may just use the error pattern which blinks red at very high priority.


Code:
#!/bin/sh

# copy this to /usr/sbin/batlow.sh
# start it with:
# start-stop-daemon -b -p /var/run/batlow.pid -a /usr/sbin/batlow.sh -S

# Default error pattern is always present bit may be inapprobiate
#BATTERYLOW_PATTERN=PatternError

# When you defined your own pattern:
BATTERYLOW_PATTERN=PatternBatteryLow

dbus-monitor --system \
	"type='signal',member='charger_connected'" \
	"type='signal',member='battery_low'" | \
while read signal; do
	case "$signal" in
	*charger_connected*)
		echo "charger connected"
		dbus-send --system --dest="com.nokia.mce" --type=method_call \
			"/com/nokia/mce/request" "com.nokia.mce.request.req_led_pattern_deactivate" \
			"string:$BATTERYLOW_PATTERN" 
		;;
	*battery_low*)
		echo "battery low"
		dbus-send --system --dest="com.nokia.mce" --type=method_call \
			"/com/nokia/mce/request" "com.nokia.mce.request.req_led_pattern_activate" \
			"string:$BATTERYLOW_PATTERN" 
		;;
	esac
done
 

The Following 15 Users Say Thank You to cehteh For This Useful Post:
ossipena's Avatar
Posts: 3,159 | Thanked: 2,023 times | Joined on Feb 2008 @ Finland
#2
http://wiki.maemo.org/Templateanger
__________________
Want to know something?
K.I.S.S. approach:
wiki category:beginners. Browse it through and you'll be much wiser!
If the link doesn't help, just use
Google Custom Search
 
Posts: 235 | Thanked: 89 times | Joined on Oct 2009 @ italy
#3
thank you cehteh for your script. I'll use it, really useful. but more important for me is to understand. please, can you explain your script? what means each code line?
eg:
1.what means com.nokia.mce, is it a web address?
2.why you didn't use a simpler one-line command like PatternbatteryLow=(code) in /etc/mce/mce.ini instead of script? we need both?
what I've to write in /init.d directory? a new file or I've to modify existing mce file?
please, don't forget to the newbies too and help them to understand.
thank you cehteh
__________________
If you found my post useful please thank me, I appreciate!

Last edited by maemo.it; 2011-01-15 at 02:28.
 
Posts: 235 | Thanked: 86 times | Joined on Dec 2010
#4
Originally Posted by ossipena View Post
http://wiki.maemo.org/Templateanger
could you tell me what danger might be caused by this script? since I don't find anything dangerous other than IF YOU DECIDED TO deal with /etc/mce/mce.ini with your own LED pattern
otherwise this should be safe. or am I wrong?

Originally Posted by maemo.it View Post
thank you cehteh for your script. I'll use it, really useful. but more important for me is to understand. please, can you explain your script? what means each code line?
eg:
1.what means com.nokia.mce, is it a web address?
2.why you didn't use a simpler one-line command like PatternbatteryLow=(code) in /etc/mce/mce.ini instead of script? we need both?
what I've to write in /init.d directory? a new file or I've to modify existing mce file?
please, don't forget to the newbies too and help them to understand.
thank you cehteh
1) no. please go http://dbus.freedesktop.org/doc/dbus-tutorial.html or http://linux.die.net/man/1/dbus-monitor for details
2) you can make as many as LED pattern in mce.ini, but if nothing ever triggered it (such as "scripts"), then it'll do nothing

please correct me if I'm wrong
 
xxxxts's Avatar
Posts: 491 | Thanked: 341 times | Joined on Nov 2009 @ LA
#5
This is not working for me...
 
Posts: 235 | Thanked: 86 times | Joined on Dec 2010
#6
Originally Posted by xxxxts View Post
This is not working for me...
above code is meant for those who've had PatternBatteryLow in their mce.ini
have you set PatternBatteryLow in yours?
if you haven't, and you don't wish to hassle with your mce.ini, change the code like below

Code:
# Default error pattern is always present bit may be inapprobiate
BATTERYLOW_PATTERN=PatternError

# When you defined your own pattern:
#BATTERYLOW_PATTERN=PatternBatteryLow
 
xxxxts's Avatar
Posts: 491 | Thanked: 341 times | Joined on Nov 2009 @ LA
#7
I inserted PatternBatteryLow in mce.ini, no luck - I also tried changing to PatternError but still no go...
 
Posts: 235 | Thanked: 86 times | Joined on Dec 2010
#8
try move the script to /home/user, and run it using X-Term and see if it works

it should not print anything unless triggered by battery low notification or changer being connected. if you see some lines while running the script, there might be an error while copying the code

please also make sure that "/com/nokia/mce/request" and "com.nokia.mce.request.req_led_pattern_activat e/deactivate" are in the same line (the code on my browser, it looked as if they're on different lines). or add trailing backslash after "/com/nokia/mce/request" (there are 2 of them, change both)

Code:
		dbus-send --system --dest="com.nokia.mce" --type=method_call \
			"/com/nokia/mce/request" \
			"com.nokia.mce.request.req_led_pattern_deactivate" \
			"string:$BATTERYLOW_PATTERN"

Last edited by figaro; 2011-02-10 at 15:05.
 
pH5's Avatar
Posts: 138 | Thanked: 375 times | Joined on Aug 2009 @ Berlin
#9
Originally Posted by cehteh View Post
I posting this here, maybe someone has use for it or may even package it (or implement it in C).
I've implemented the script in Vala and packaged it as Low Battery LED (lowbatled).
If there is no PatternBatteryLow in mce.ini, the package postinst will add it using mceledpattern and restart MCE.
 

The Following 4 Users Say Thank You to pH5 For This Useful Post:
hawaii's Avatar
Posts: 1,030 | Thanked: 792 times | Joined on Jun 2009
#10
A lot of these small daemons can be translated into scripts that run on dbuscron, it would be a lot easier to manage and might reduce ticks.

Just an observation.
 

The Following 4 Users Say Thank You to hawaii For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 06:29.