|
#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 |
|
#2
|
||||
|
||||
|
__________________
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 |
|
#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. |
|
#4
|
|||
|
|||
|
Quote:
otherwise this should be safe. or am I wrong? Quote:
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 |
|
#5
|
||||
|
||||
|
This is not working for me...
|
|
#6
|
|||
|
|||
|
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 |
|
#7
|
||||
|
||||
|
I inserted PatternBatteryLow in mce.ini, no luck - I also tried changing to PatternError but still no go...
|
|
#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. |
|
#9
|
||||
|
|
||||
|
Quote:
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: | ||
|
#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: | ||
![]() |
|
|