I have some older laptosps, where the battery-plugin always shows 0:00
as remaining time in discharching mode. (I think this is because
"current_now" in sys/class/power_supply always stays 0 - ACPI problem?).
The alarm option only checks remaining time and thus doesn't work. I
propose to also have the opportunity to set a % level for the alarm to
run.

I send a patch that is based on lxpanel-0.8.0 but I was not able to test
it. I could not compile lxpanel on my stable machine, sorry.

The idea is to have alarmTime and alarmPercent in parallel and run the
alarm command whichever level is hit first. So if alarmPercent ist set
to 0 only the alarmTime is considered which should lead to the current
behavior.

I hope this is a good idea and that there's no coarse
error in my reasoning.

Thanks, Christoph Sobotka



*** lxpanel-0.8.0/plugins/batt/batt.c	2014-12-07 17:18:06.000000000 +0100
--- lxpanel-0.8.0_plugins_batt_batt.c	2015-04-02 23:15:29.217378346 +0200
***************
*** 70,75 ****
--- 70,76 ----
      GtkWidget *drawingArea;
      GtkOrientation orientation;
      unsigned int alarmTime,
+         alarmPercent,
          border,
          height,
          length,
***************
*** 247,254 ****
      isCharging = battery_is_charging ( b );
  
      /* Consider running the alarm command */
!     if ( !isCharging && rate > 0 &&
!         ( ( battery_get_remaining( b ) / 60 ) < (int)lx_b->alarmTime ) )
      {
          /* FIXME: this should be done using glibs process functions */
          /* FIXME: see bug #463: it should not spawn process all the time */
--- 248,257 ----
      isCharging = battery_is_charging ( b );
  
      /* Consider running the alarm command */
!     if ( !isCharging && (
!          ( rate > 0 && ( ( battery_get_remaining( b ) / 60 ) < (int)lx_b->alarmTime ) ) ||
!          ( lx_b->b->percentage < (int)lx_b->alarmPercent ) )
!        )
      {
          /* FIXME: this should be done using glibs process functions */
          /* FIXME: see bug #463: it should not spawn process all the time */
***************
*** 460,465 ****
--- 463,469 ----
  
      /* Set default values for integers */
      lx_b->alarmTime = 5;
+     lx_b->alarmPercent = 0;
      lx_b->requestedBorder = 1;
      lx_b->thickness = 8;
  
***************
*** 485,490 ****
--- 489,496 ----
          lx_b->dischargingColor2 = g_strdup(str);
      if (config_setting_lookup_int(settings, "AlarmTime", &tmp_int))
          lx_b->alarmTime = MAX(0, tmp_int);
+     if (config_setting_lookup_int(settings, "AlarmPercent", &tmp_int))
+         lx_b->alarmPercent = MAX(0, tmp_int);
      if (config_setting_lookup_int(settings, "BorderWidth", &tmp_int))
          lx_b->requestedBorder = CLAMP(tmp_int, 0, 6);
      if (config_setting_lookup_int(settings, "Size", &tmp_int))
***************
*** 650,655 ****
--- 656,662 ----
      config_group_set_int(b->settings, "HideIfNoBattery", b->hide_if_no_battery);
      config_group_set_string(b->settings, "AlarmCommand", b->alarmCommand);
      config_group_set_int(b->settings, "AlarmTime", b->alarmTime);
+     config_group_set_int(b->settings, "AlarmPercent", b->alarmPercent);
      config_group_set_int(b->settings, "BorderWidth", b->requestedBorder);
      config_group_set_int(b->settings, "Size", b->thickness);
      config_group_set_int(b->settings, "ShowExtendedInformation",
***************
*** 666,671 ****
--- 673,679 ----
              _("Hide if there is no battery"), &b->hide_if_no_battery, CONF_TYPE_BOOL,
              _("Alarm command"), &b->alarmCommand, CONF_TYPE_STR,
              _("Alarm time (minutes left)"), &b->alarmTime, CONF_TYPE_INT,
+             _("Alarm percentage (percent left)"), &b->alarmPercent, CONF_TYPE_INT,
              _("Background color"), &b->backgroundColor, CONF_TYPE_STR,
              _("Charging color 1"), &b->chargingColor1, CONF_TYPE_STR,
              _("Charging color 2"), &b->chargingColor2, CONF_TYPE_STR,
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Lxde-list mailing list
Lxde-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxde-list

Reply via email to