View Single Post
pH5's Avatar
Posts: 138 | Thanked: 375 times | Joined on Aug 2009 @ Berlin
#18
Originally Posted by xxxxts View Post
Is this the most efficient way of doing this?
No. The most efficient way would be to add this to the libbattery.so module of the mce daemon because this is running anyway. And guess what, mce is now open source!
After downloading the MeeGo mce from http://meego.gitorious.org/meego-middleware/mce and applying the patch below, I ran "make modules/libbattery.so" and put the result into /usr/lib/mce/modules. It seems to work, but I'm still waiting for the next battery_low signal to verify.

Code:
diff --git a/modules/battery.c b/modules/battery.c
index cec3f0d..a1ab114 100644
--- a/modules/battery.c
+++ b/modules/battery.c
@@ -129,7 +129,7 @@ static gboolean battery_ok_dbus_cb(DBusMessage *const msg)
 	mce_log(LL_DEBUG,
 		"Received battery ok signal");
 
-//	execute_datapipe_output_triggers(&led_pattern_deactivate_pipe, MCE_LED_PATTERN_BATTERY_LOW, USE_INDATA);
+	execute_datapipe_output_triggers(&led_pattern_deactivate_pipe, MCE_LED_PATTERN_BATTERY_LOW, USE_INDATA);
 
 	execute_datapipe(&battery_status_pipe,
 			 GINT_TO_POINTER(BATTERY_STATUS_OK),
@@ -156,7 +156,7 @@ static gboolean battery_low_dbus_cb(DBusMessage *const msg)
 	mce_log(LL_DEBUG,
 		"Received battery low signal");
 
-//	execute_datapipe_output_triggers(&led_pattern_activate_pipe, MCE_LED_PATTERN_BATTERY_LOW, USE_INDATA);
+	execute_datapipe_output_triggers(&led_pattern_activate_pipe, MCE_LED_PATTERN_BATTERY_LOW, USE_INDATA);
 
 	execute_datapipe(&battery_status_pipe,
 			 GINT_TO_POINTER(BATTERY_STATUS_LOW),
@@ -263,7 +263,7 @@ static gboolean charger_charging_on_dbus_cb(DBusMessage *const msg)
 
 	/* In case these are active; there's no harm to call them anyway */
 	execute_datapipe_output_triggers(&led_pattern_deactivate_pipe, MCE_LED_PATTERN_BATTERY_FULL, USE_INDATA);
-//	execute_datapipe_output_triggers(&led_pattern_deactivate_pipe, MCE_LED_PATTERN_BATTERY_LOW, USE_INDATA);
+	execute_datapipe_output_triggers(&led_pattern_deactivate_pipe, MCE_LED_PATTERN_BATTERY_LOW, USE_INDATA);
 
 	execute_datapipe_output_triggers(&led_pattern_activate_pipe, MCE_LED_PATTERN_BATTERY_CHARGING, USE_INDATA);
Originally Posted by xxxxts View Post
Is this way more efficient than the script (or is it exactly the same)?
Does the daemon only activate when triggered by the low battery or is it always running?
The daemon is sleeping most of the time, it is only woken up by the D-Bus signals. And so is the script. Of course the daemon is way more efficient once the signal comes in, but given the expected frequency of battery_low signals this isn't worth all that much. It occupies less memory though.
 

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