View Single Post
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: