Go Back   maemo.org - Talk > Software > Applications
 
Register FAQ Community Calendar Today's Posts Search

Notices

Reply
 
Thread Tools
  #1  
Old 2010-03-03, 09:29
cehteh cehteh is offline
 
Join Date: Jan 2010
Posts: 12
Thanks!: 0
Thanked 28 Times in 6 Posts
Default Blink Notification led on Battery Low

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
Reply With Quote
The Following 15 Users Say Thank You to cehteh For This Useful Post:
  #2  
Old 2010-03-03, 09:36
ossipena's Avatar
ossipena ossipena is offline
 
Join Date: Feb 2008
Location: Finland
Posts: 3,159
Thanks!: 3,087
Thanked 2,023 Times in 993 Posts
Default Re: Blink Notification led on Battery Low

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
Reply With Quote
  #3  
Old 2011-01-15, 02:25
maemo.it maemo.it is offline
 
Join Date: Oct 2009
Location: italy
Posts: 235
Thanks!: 168
Thanked 89 Times in 26 Posts
Default Re: Blink Notification led on Battery Low

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.
Reply With Quote
  #4  
Old 2011-02-10, 10:20
figaro figaro is offline
 
Join Date: Dec 2010
Posts: 235
Thanks!: 252
Thanked 86 Times in 55 Posts
Default Re: Blink Notification led on Battery Low

Quote:
Originally Posted by ossipena View Post
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?

Quote:
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
Reply With Quote
  #5  
Old 2011-02-10, 12:37
xxxxts's Avatar
xxxxts xxxxts is offline
 
Join Date: Nov 2009
Location: LA
Posts: 491
Thanks!: 94
Thanked 341 Times in 134 Posts
Default Re: Blink Notification led on Battery Low

This is not working for me...
Reply With Quote
  #6  
Old 2011-02-10, 13:29
figaro figaro is offline
 
Join Date: Dec 2010
Posts: 235
Thanks!: 252
Thanked 86 Times in 55 Posts
Default Re: Blink Notification led on Battery Low

Quote:
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
Reply With Quote
  #7  
Old 2011-02-10, 14:21
xxxxts's Avatar
xxxxts xxxxts is offline
 
Join Date: Nov 2009
Location: LA
Posts: 491
Thanks!: 94
Thanked 341 Times in 134 Posts
Default Re: Blink Notification led on Battery Low

I inserted PatternBatteryLow in mce.ini, no luck - I also tried changing to PatternError but still no go...
Reply With Quote
  #8  
Old 2011-02-10, 14:36
figaro figaro is offline
 
Join Date: Dec 2010
Posts: 235
Thanks!: 252
Thanked 86 Times in 55 Posts
Default Re: Blink Notification led on Battery Low

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.
Reply With Quote
  #9  
Old 2011-02-10, 16:43
pH5's Avatar
pH5 pH5 is offline
 
Join Date: Aug 2009
Location: Berlin
Posts: 138
Thanks!: 184
Thanked 375 Times in 86 Posts
Send a message via ICQ to pH5
Default Re: Blink Notification led on Battery Low

Quote:
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.
Reply With Quote
The Following 4 Users Say Thank You to pH5 For This Useful Post:
  #10  
Old 2011-02-10, 17:02
hawaii's Avatar
hawaii hawaii is offline
 
Join Date: Jun 2009
Posts: 1,030
Thanks!: 317
Thanked 792 Times in 376 Posts
Default Re: Blink Notification led on Battery Low

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.
Reply With Quote
The Following 4 Users Say Thank You to hawaii For This Useful Post:
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 17:32.