Add G_BEGIN_DECLS and G_END_DECLS to public headers, some compilers require that.
[lxde/lxpanel.git] / src / plugins / batt / batt.c
1 /*
2 * ACPI battery monitor plugin for LXPanel
3 *
4 * Copyright (C) 2007 by Greg McNew <gmcnew@gmail.com>
5 * Copyright (C) 2008 by Hong Jen Yee <pcman.tw@gmail.com>
6 * Copyright (C) 2009 by Juergen Hoetzel <juergen@archlinux.org>
7 * Copyright (C) 2014 by Andriy Grytsenko <andrej@rep.kiev.ua>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 *
24 * This plugin monitors battery usage on ACPI-enabled systems by reading the
25 * battery information found in /sys/class/power_supply. The update interval is
26 * user-configurable and defaults to 3 second.
27 *
28 * The battery's remaining life is estimated from its current charge and current
29 * rate of discharge. The user may configure an alarm command to be run when
30 * their estimated remaining battery life reaches a certain level.
31 */
32
33 /* FIXME:
34 * Here are somethings need to be improvec:
35 * 1. Replace pthread stuff with gthread counterparts for portability.
36 * 3. Add an option to hide the plugin when AC power is used or there is no battery.
37 * 4. Handle failure gracefully under systems other than Linux.
38 */
39
40 #include <glib.h>
41 #include <glib/gi18n.h>
42 #include <pthread.h> /* used by pthread_create() and alarmThread */
43 #include <semaphore.h> /* used by update() and alarmProcess() for alarms */
44 #include <stdlib.h>
45 #include <string.h>
46 #include <stdarg.h>
47
48 #include "dbg.h" /* for ENTER and RET macros */
49 #include "batt_sys.h"
50 #include "misc.h" /* used for lxpanel_generic_config_dlg() */
51 #include "plugin.h" /* all other APIs including panel configuration */
52
53 /* The last MAX_SAMPLES samples are averaged when charge rates are evaluated.
54 This helps prevent spikes in the "time left" values the user sees. */
55 #define MAX_SAMPLES 10
56
57 typedef struct {
58 char *alarmCommand,
59 *backgroundColor,
60 *chargingColor1,
61 *chargingColor2,
62 *dischargingColor1,
63 *dischargingColor2;
64 GdkColor background,
65 charging1,
66 charging2,
67 discharging1,
68 discharging2;
69 cairo_surface_t *pixmap;
70 GtkWidget *drawingArea;
71 GtkOrientation orientation;
72 unsigned int alarmTime,
73 border,
74 height,
75 length,
76 numSamples,
77 requestedBorder,
78 *rateSamples,
79 rateSamplesSum,
80 thickness,
81 timer,
82 state_elapsed_time,
83 info_elapsed_time,
84 wasCharging,
85 width,
86 hide_if_no_battery;
87 sem_t alarmProcessLock;
88 battery* b;
89 gboolean has_ac_adapter;
90 gboolean show_extended_information;
91 LXPanel *panel;
92 config_setting_t *settings;
93 } lx_battery;
94
95
96 typedef struct {
97 char *command;
98 sem_t *lock;
99 } Alarm;
100
101 static void destructor(gpointer data);
102 static void update_display(lx_battery *lx_b, gboolean repaint);
103
104 /* alarmProcess takes the address of a dynamically allocated alarm struct (which
105 it must free). It ensures that alarm commands do not run concurrently. */
106 static void * alarmProcess(void *arg) {
107 Alarm *a = (Alarm *) arg;
108
109 sem_wait(a->lock);
110 if (system(a->command) != 0)
111 g_warning("plugin batt: failed to execute alarm command \"%s\"", a->command);
112 sem_post(a->lock);
113
114 g_free(a);
115 return NULL;
116 }
117
118
119 static void append(gchar **tooltip, gchar *fmt, ...)
120 {
121 gchar *old = *tooltip;
122 gchar *new;
123 va_list va;
124
125 va_start(va, fmt);
126 new = g_strdup_vprintf(fmt, va);
127 va_end(va);
128
129 *tooltip = g_strconcat(old, new, NULL);
130
131 g_free(old);
132 g_free(new);
133 }
134
135
136 /* Make a tooltip string, and display remaining charge time if the battery
137 is charging or remaining life if it's discharging */
138 static gchar* make_tooltip(lx_battery* lx_b, gboolean isCharging)
139 {
140 gchar * tooltip;
141 gchar * indent = " ";
142 battery *b = lx_b->b;
143
144 if (b == NULL)
145 return NULL;
146
147 if (isCharging) {
148 int hours = lx_b->b->seconds / 3600;
149 int left_seconds = lx_b->b->seconds - 3600 * hours;
150 int minutes = left_seconds / 60;
151 tooltip = g_strdup_printf(
152 _("Battery: %d%% charged, %d:%02d until full"),
153 lx_b->b->percentage,
154 hours,
155 minutes );
156 } else {
157 /* if we have enough rate information for battery */
158 if (lx_b->b->percentage != 100) {
159 int hours = lx_b->b->seconds / 3600;
160 int left_seconds = lx_b->b->seconds - 3600 * hours;
161 int minutes = left_seconds / 60;
162 tooltip = g_strdup_printf(
163 _("Battery: %d%% charged, %d:%02d left"),
164 lx_b->b->percentage,
165 hours,
166 minutes );
167 } else {
168 tooltip = g_strdup_printf(
169 _("Battery: %d%% charged"),
170 100 );
171 }
172 }
173
174 if (!lx_b->show_extended_information) {
175 return tooltip;
176 }
177
178 if (b->energy_full_design != -1)
179 append(&tooltip, _("\n%sEnergy full design:\t\t%5d mWh"), indent, b->energy_full_design);
180 if (b->energy_full != -1)
181 append(&tooltip, _("\n%sEnergy full:\t\t\t%5d mWh"), indent, b->energy_full);
182 if (b->energy_now != -1)
183 append(&tooltip, _("\n%sEnergy now:\t\t\t%5d mWh"), indent, b->energy_now);
184 if (b->power_now != -1)
185 append(&tooltip, _("\n%sPower now:\t\t\t%5d mW"), indent, b->power_now);
186
187 if (b->charge_full_design != -1)
188 append(&tooltip, _("\n%sCharge full design:\t%5d mAh"), indent, b->charge_full_design);
189 if (b->charge_full != -1)
190 append(&tooltip, _("\n%sCharge full:\t\t\t%5d mAh"), indent, b->charge_full);
191 if (b->charge_now != -1)
192 append(&tooltip, _("\n%sCharge now:\t\t\t%5d mAh"), indent, b->charge_now);
193 if (b->current_now != -1)
194 append(&tooltip, _("\n%sCurrent now:\t\t\t%5d mA"), indent, b->current_now);
195
196 if (b->voltage_now != -1)
197 append(&tooltip, _("\n%sCurrent Voltage:\t\t%.3lf V"), indent, b->voltage_now / 1000.0);
198
199 return tooltip;
200 }
201
202 static void set_tooltip_text(lx_battery* lx_b)
203 {
204 if (lx_b->b == NULL)
205 return;
206 gboolean isCharging = battery_is_charging(lx_b->b);
207 gchar *tooltip = make_tooltip(lx_b, isCharging);
208 gtk_widget_set_tooltip_text(lx_b->drawingArea, tooltip);
209 g_free(tooltip);
210 }
211
212 /* FIXME:
213 Don't repaint if percentage of remaining charge and remaining time aren't changed. */
214 void update_display(lx_battery *lx_b, gboolean repaint) {
215 cairo_t *cr;
216 battery *b = lx_b->b;
217 /* unit: mW */
218 int rate;
219 gboolean isCharging;
220
221 if (! lx_b->pixmap )
222 return;
223
224 cr = cairo_create(lx_b->pixmap);
225 cairo_set_line_width (cr, 1.0);
226
227 /* draw background */
228 gdk_cairo_set_source_color(cr, &lx_b->background);
229 cairo_rectangle(cr, 0, 0, lx_b->width, lx_b->height);
230 cairo_fill(cr);
231
232 /* no battery is found */
233 if( b == NULL )
234 {
235 gtk_widget_set_tooltip_text( lx_b->drawingArea, _("No batteries found") );
236 if (lx_b->hide_if_no_battery)
237 {
238 gtk_widget_hide(gtk_widget_get_parent(lx_b->drawingArea));
239 repaint = FALSE;
240 }
241 goto update_done;
242 }
243
244 /* fixme: only one battery supported */
245
246 rate = lx_b->b->current_now;
247 isCharging = battery_is_charging ( b );
248
249 /* Consider running the alarm command */
250 if ( !isCharging && rate > 0 &&
251 ( ( battery_get_remaining( b ) / 60 ) < (int)lx_b->alarmTime ) )
252 {
253 /* Shrug this should be done using glibs process functions */
254 /* Alarms should not run concurrently; determine whether an alarm is
255 already running */
256 int alarmCanRun;
257 sem_getvalue(&(lx_b->alarmProcessLock), &alarmCanRun);
258
259 /* Run the alarm command if it isn't already running */
260 if (alarmCanRun) {
261
262 Alarm *a = (Alarm *) malloc(sizeof(Alarm));
263 a->command = lx_b->alarmCommand;
264 a->lock = &(lx_b->alarmProcessLock);
265
266 /* Manage the alarm process in a new thread, which which will be
267 responsible for freeing the alarm struct it's given */
268 pthread_t alarmThread;
269 pthread_create(&alarmThread, NULL, alarmProcess, a);
270 }
271 }
272
273 set_tooltip_text(lx_b);
274
275 int chargeLevel = lx_b->b->percentage * (lx_b->length - 2 * lx_b->border) / 100;
276
277 if (lx_b->orientation == GTK_ORIENTATION_HORIZONTAL) {
278
279 /* Draw the battery bar vertically, using color 1 for the left half and
280 color 2 for the right half */
281 gdk_cairo_set_source_color(cr,
282 isCharging ? &lx_b->charging1 : &lx_b->discharging1);
283 cairo_rectangle(cr, lx_b->border,
284 lx_b->height - lx_b->border - chargeLevel, lx_b->width / 2
285 - lx_b->border, chargeLevel);
286 cairo_fill(cr);
287 gdk_cairo_set_source_color(cr,
288 isCharging ? &lx_b->charging2 : &lx_b->discharging2);
289 cairo_rectangle(cr, lx_b->width / 2,
290 lx_b->height - lx_b->border - chargeLevel, (lx_b->width + 1) / 2
291 - lx_b->border, chargeLevel);
292 cairo_fill(cr);
293
294 }
295 else {
296
297 /* Draw the battery bar horizontally, using color 1 for the top half and
298 color 2 for the bottom half */
299 gdk_cairo_set_source_color(cr,
300 isCharging ? &lx_b->charging1 : &lx_b->discharging1);
301 cairo_rectangle(cr, lx_b->border,
302 lx_b->border, chargeLevel, lx_b->height / 2 - lx_b->border);
303 cairo_fill(cr);
304 gdk_cairo_set_source_color(cr,
305 isCharging ? &lx_b->charging2 : &lx_b->discharging2);
306 cairo_rectangle(cr, lx_b->border, (lx_b->height + 1)
307 / 2, chargeLevel, lx_b->height / 2 - lx_b->border);
308 cairo_fill(cr);
309
310 }
311 gtk_widget_show(gtk_widget_get_parent(lx_b->drawingArea));
312
313 update_done:
314 if( repaint )
315 gtk_widget_queue_draw( lx_b->drawingArea );
316
317 check_cairo_status(cr);
318 cairo_destroy(cr);
319 }
320
321 /* This callback is called every 3 seconds */
322 static int update_timout(lx_battery *lx_b) {
323 battery *bat;
324 if (g_source_is_destroyed(g_main_current_source()))
325 return FALSE;
326 GDK_THREADS_ENTER();
327 lx_b->state_elapsed_time++;
328 lx_b->info_elapsed_time++;
329
330 bat = battery_update( lx_b->b );
331 if (bat == NULL)
332 {
333 battery_free(lx_b->b);
334
335 /* maybe in the mean time a battery has been inserted. */
336 lx_b->b = battery_get();
337 }
338
339 update_display( lx_b, TRUE );
340
341 GDK_THREADS_LEAVE();
342 return TRUE;
343 }
344
345 /* An update will be performed whenever the user clicks on the charge bar */
346 static gboolean buttonPressEvent(GtkWidget *p, GdkEventButton *event,
347 LXPanel *panel)
348 {
349 lx_battery *lx_b = lxpanel_plugin_get_data(p);
350
351 update_display(lx_b, TRUE);
352 /* FIXME: open some application for lid/power management may be? */
353
354 return FALSE;
355 }
356
357
358 static gint configureEvent(GtkWidget *widget, GdkEventConfigure *event,
359 lx_battery *lx_b)
360 {
361 GtkAllocation allocation;
362
363 ENTER;
364
365 gtk_widget_get_allocation(widget, &allocation);
366 if (allocation.width <= 1 && allocation.height <= 1)
367 {
368 /* If plugin is hidden currently then we get 1x1 here */
369 RET(TRUE);
370 }
371
372 if (lx_b->pixmap)
373 cairo_surface_destroy(lx_b->pixmap);
374
375 /* Update the plugin's dimensions */
376 lx_b->width = allocation.width;
377 lx_b->height = allocation.height;
378 if (lx_b->orientation == GTK_ORIENTATION_HORIZONTAL) {
379 lx_b->length = lx_b->height;
380 lx_b->thickness = lx_b->width;
381 }
382 else {
383 lx_b->length = lx_b->width;
384 lx_b->thickness = lx_b->height;
385 }
386
387 lx_b->pixmap = cairo_image_surface_create (CAIRO_FORMAT_RGB24, allocation.width,
388 allocation.height);
389 check_cairo_surface_status(&lx_b->pixmap);
390
391 /* Perform an update so the bar will look right in its new orientation */
392 update_display(lx_b, FALSE);
393
394 RET(TRUE);
395 }
396
397
398 static gint exposeEvent(GtkWidget *widget, GdkEventExpose *event, lx_battery *lx_b) {
399
400 ENTER;
401 cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(widget));
402 GtkStyle *style = gtk_widget_get_style(lx_b->drawingArea);
403
404 gdk_cairo_region(cr, event->region);
405 cairo_clip(cr);
406
407 gdk_cairo_set_source_color(cr, &style->black);
408 cairo_set_source_surface(cr, lx_b->pixmap, 0, 0);
409 cairo_paint(cr);
410
411 check_cairo_status(cr);
412 cairo_destroy(cr);
413
414 RET(FALSE);
415 }
416
417
418 static GtkWidget * constructor(LXPanel *panel, config_setting_t *settings)
419 {
420 ENTER;
421
422 lx_battery *lx_b;
423 GtkWidget *p;
424 const char *str;
425 int tmp_int;
426
427 lx_b = g_new0(lx_battery, 1);
428
429 /* get available battery */
430 lx_b->b = battery_get ();
431
432 p = gtk_event_box_new();
433 lxpanel_plugin_set_data(p, lx_b, destructor);
434 gtk_widget_set_has_window(p, FALSE);
435 gtk_container_set_border_width( GTK_CONTAINER(p), 1 );
436
437 lx_b->drawingArea = gtk_drawing_area_new();
438 gtk_widget_add_events( lx_b->drawingArea, GDK_BUTTON_PRESS_MASK );
439
440 gtk_container_add( (GtkContainer*)p, lx_b->drawingArea );
441
442 lx_b->orientation = panel_get_orientation(panel);
443 if (lx_b->orientation == GTK_ORIENTATION_HORIZONTAL) {
444 lx_b->height = lx_b->length = 20;
445 lx_b->thickness = lx_b->width = 8;
446 }
447 else {
448 lx_b->height = lx_b->thickness = 8;
449 lx_b->length = lx_b->width = 20;
450 }
451 gtk_widget_set_size_request(lx_b->drawingArea, lx_b->width, lx_b->height);
452
453 gtk_widget_show(lx_b->drawingArea);
454
455 g_signal_connect (G_OBJECT (lx_b->drawingArea),"configure-event",
456 G_CALLBACK (configureEvent), (gpointer) lx_b);
457 g_signal_connect (G_OBJECT (lx_b->drawingArea), "expose-event",
458 G_CALLBACK (exposeEvent), (gpointer) lx_b);
459
460 sem_init(&(lx_b->alarmProcessLock), 0, 1);
461
462 lx_b->alarmCommand = lx_b->backgroundColor = lx_b->chargingColor1 = lx_b->chargingColor2
463 = lx_b->dischargingColor1 = lx_b->dischargingColor2 = NULL;
464
465 /* Set default values for integers */
466 lx_b->alarmTime = 5;
467 lx_b->requestedBorder = 1;
468
469 /* remember instance data */
470 lx_b->panel = panel;
471 lx_b->settings = settings;
472
473 lx_b->show_extended_information = false;
474
475 if (config_setting_lookup_int(settings, "HideIfNoBattery", &tmp_int))
476 lx_b->hide_if_no_battery = (tmp_int != 0);
477 if (config_setting_lookup_string(settings, "AlarmCommand", &str))
478 lx_b->alarmCommand = g_strdup(str);
479 if (config_setting_lookup_string(settings, "BackgroundColor", &str))
480 lx_b->backgroundColor = g_strdup(str);
481 if (config_setting_lookup_string(settings, "ChargingColor1", &str))
482 lx_b->chargingColor1 = g_strdup(str);
483 if (config_setting_lookup_string(settings, "ChargingColor2", &str))
484 lx_b->chargingColor2 = g_strdup(str);
485 if (config_setting_lookup_string(settings, "DischargingColor1", &str))
486 lx_b->dischargingColor1 = g_strdup(str);
487 if (config_setting_lookup_string(settings, "DischargingColor2", &str))
488 lx_b->dischargingColor2 = g_strdup(str);
489 if (config_setting_lookup_int(settings, "AlarmTime", &tmp_int))
490 lx_b->alarmTime = MAX(0, tmp_int);
491 if (config_setting_lookup_int(settings, "BorderWidth", &tmp_int))
492 lx_b->requestedBorder = MAX(0, tmp_int);
493 if (config_setting_lookup_int(settings, "Size", &tmp_int)) {
494 lx_b->thickness = MAX(1, tmp_int);
495 if (lx_b->orientation == GTK_ORIENTATION_HORIZONTAL)
496 lx_b->width = lx_b->thickness;
497 else
498 lx_b->height = lx_b->thickness;
499 gtk_widget_set_size_request(lx_b->drawingArea, lx_b->width,
500 lx_b->height);
501 }
502 if (config_setting_lookup_int(settings, "ShowExtendedInformation", &tmp_int))
503 lx_b->show_extended_information = (tmp_int != 0);
504
505 /* Make sure the border value is acceptable */
506 lx_b->border = MIN(lx_b->requestedBorder,
507 (MAX(1, MIN(lx_b->length, lx_b->thickness)) - 1) / 2);
508
509 /* Apply more default options */
510 if (! lx_b->alarmCommand)
511 lx_b->alarmCommand = g_strdup("xmessage Battery low");
512 if (! lx_b->backgroundColor)
513 lx_b->backgroundColor = g_strdup("black");
514 if (! lx_b->chargingColor1)
515 lx_b->chargingColor1 = g_strdup("#28f200");
516 if (! lx_b->chargingColor2)
517 lx_b->chargingColor2 = g_strdup("#22cc00");
518 if (! lx_b->dischargingColor1)
519 lx_b->dischargingColor1 = g_strdup("#ffee00");
520 if (! lx_b->dischargingColor2)
521 lx_b->dischargingColor2 = g_strdup("#d9ca00");
522
523 gdk_color_parse(lx_b->backgroundColor, &lx_b->background);
524 gdk_color_parse(lx_b->chargingColor1, &lx_b->charging1);
525 gdk_color_parse(lx_b->chargingColor2, &lx_b->charging2);
526 gdk_color_parse(lx_b->dischargingColor1, &lx_b->discharging1);
527 gdk_color_parse(lx_b->dischargingColor2, &lx_b->discharging2);
528
529 /* Start the update loop */
530 lx_b->timer = g_timeout_add_seconds( 9, (GSourceFunc) update_timout, (gpointer) lx_b);
531
532 RET(p);
533 }
534
535
536 static void
537 destructor(gpointer data)
538 {
539 ENTER;
540
541 lx_battery *b = (lx_battery *)data;
542
543 if (b->b != NULL)
544 battery_free(b->b);
545
546 if (b->pixmap)
547 cairo_surface_destroy(b->pixmap);
548
549 g_free(b->alarmCommand);
550 g_free(b->backgroundColor);
551 g_free(b->chargingColor1);
552 g_free(b->chargingColor2);
553 g_free(b->dischargingColor1);
554 g_free(b->dischargingColor2);
555
556 g_free(b->rateSamples);
557 sem_destroy(&(b->alarmProcessLock));
558 if (b->timer)
559 g_source_remove(b->timer);
560 g_free(b);
561
562 RET();
563
564 }
565
566
567 static void orientation(LXPanel *panel, GtkWidget *p) {
568
569 ENTER;
570
571 lx_battery *b = lxpanel_plugin_get_data(p);
572
573 if (b->orientation != panel_get_orientation(panel)) {
574 b->orientation = panel_get_orientation(panel);
575 unsigned int swap = b->height;
576 b->height = b->width;
577 b->width = swap;
578 gtk_widget_set_size_request(b->drawingArea, b->width, b->height);
579 }
580
581 RET();
582 }
583
584
585 static gboolean applyConfig(gpointer user_data)
586 {
587 ENTER;
588
589 lx_battery *b = lxpanel_plugin_get_data(user_data);
590
591 /* Update colors */
592 if (b->backgroundColor &&
593 gdk_color_parse(b->backgroundColor, &b->background))
594 config_group_set_string(b->settings, "BackgroundColor", b->backgroundColor);
595 if (b->chargingColor1 && gdk_color_parse(b->chargingColor1, &b->charging1))
596 config_group_set_string(b->settings, "ChargingColor1", b->chargingColor1);
597 if (b->chargingColor2 && gdk_color_parse(b->chargingColor2, &b->charging2))
598 config_group_set_string(b->settings, "ChargingColor2", b->chargingColor2);
599 if (b->dischargingColor1 &&
600 gdk_color_parse(b->dischargingColor1, &b->discharging1))
601 config_group_set_string(b->settings, "DischargingColor1", b->dischargingColor1);
602 if (b->dischargingColor2 &&
603 gdk_color_parse(b->dischargingColor2, &b->discharging2))
604 config_group_set_string(b->settings, "DischargingColor2", b->dischargingColor2);
605
606 /* Make sure the border value is acceptable */
607 b->border = MIN(b->requestedBorder,
608 (MAX(1, MIN(b->length, b->thickness)) - 1) / 2);
609
610 /* Resize the widget */
611 b->width = b->height = b->length;
612 if (b->orientation == GTK_ORIENTATION_HORIZONTAL)
613 b->width = b->thickness;
614 else
615 b->height = b->thickness;
616 gtk_widget_set_size_request(b->drawingArea, b->width, b->height);
617 /* ensure visibility if requested */
618 if (!b->hide_if_no_battery)
619 gtk_widget_show(user_data);
620 else if (b->b == NULL)
621 gtk_widget_hide(user_data);
622
623 /* update tooltip */
624 set_tooltip_text(b);
625
626 /* update settings */
627 config_group_set_int(b->settings, "HideIfNoBattery", b->hide_if_no_battery);
628 config_group_set_string(b->settings, "AlarmCommand", b->alarmCommand);
629 config_group_set_int(b->settings, "AlarmTime", b->alarmTime);
630 config_group_set_int(b->settings, "BorderWidth", b->requestedBorder);
631 config_group_set_int(b->settings, "Size", b->thickness);
632 config_group_set_int(b->settings, "ShowExtendedInformation",
633 b->show_extended_information);
634
635 RET(FALSE);
636 }
637
638
639 static GtkWidget *config(LXPanel *panel, GtkWidget *p) {
640 lx_battery *b = lxpanel_plugin_get_data(p);
641 return lxpanel_generic_config_dlg(_("Battery Monitor"),
642 panel, applyConfig, p,
643 _("Hide if there is no battery"), &b->hide_if_no_battery, CONF_TYPE_BOOL,
644 _("Alarm command"), &b->alarmCommand, CONF_TYPE_STR,
645 _("Alarm time (minutes left)"), &b->alarmTime, CONF_TYPE_INT,
646 _("Background color"), &b->backgroundColor, CONF_TYPE_STR,
647 _("Charging color 1"), &b->chargingColor1, CONF_TYPE_STR,
648 _("Charging color 2"), &b->chargingColor2, CONF_TYPE_STR,
649 _("Discharging color 1"), &b->dischargingColor1, CONF_TYPE_STR,
650 _("Discharging color 2"), &b->dischargingColor2, CONF_TYPE_STR,
651 _("Border width"), &b->requestedBorder, CONF_TYPE_INT,
652 _("Size"), &b->thickness, CONF_TYPE_INT,
653 _("Show Extended Information"), &b->show_extended_information, CONF_TYPE_BOOL,
654 NULL);
655 }
656
657
658 FM_DEFINE_MODULE(lxpanel_gtk, batt)
659
660 /* Plugin descriptor. */
661 LXPanelPluginInit fm_module_init_lxpanel_gtk = {
662 .name = N_("Battery Monitor"),
663 .description = N_("Display battery status using ACPI"),
664
665 .new_instance = constructor,
666 .config = config,
667 .reconfigure = orientation,
668 .button_press_event = buttonPressEvent
669 };
670
671
672 /* vim: set sw=4 sts=4 : */