+
+2009-05-15
+- merge battery applet from Sebastian Reichel <elektranox@gmail.com>
+
2009-03-14
- add systray option when convert tint-0.6 config file
but you need to stop other systemtray program
CC = gcc
FLAGS=-Wall -g `pkg-config --cflags --libs cairo pangocairo x11 xinerama xrandr imlib2 glib-2.0`
PROGNAME=tint2
-FILES=tint.c server.c panel.c config.c taskbar/task.c taskbar/taskbar.c clock/clock.c systray/systraybar.c util/window.c util/area.c
+FILES=tint.c server.c panel.c config.c taskbar/task.c taskbar/taskbar.c battery/battery.c clock/clock.c systray/systraybar.c util/window.c util/area.c
ifndef DESTDIR
ifndef PREFIX
$(PROGNAME): $(FILES) $(SYSTRAYOBJ)
- $(CC) $(CFLAGS) -I. -Iutil -Iclock -Itaskbar -Isystray -o $(PROGNAME) $(FILES) $(FLAGS)
+ $(CC) $(CFLAGS) -I. -Iutil -Ibattery -Iclock -Itaskbar -Isystray -o $(PROGNAME) $(FILES) $(FLAGS)
install: install-strip
#include "taskbar.h"
#include "systraybar.h"
#include "clock.h"
+#include "battery.h"
#include "panel.h"
#include "config.h"
#include "window.h"
static char *old_time2_font;
static Area *area_task, *area_task_active;
+static char *old_bat1_font;
+static char *old_bat2_font;
// temporary panel
static Panel *panel_config = 0;
memcpy(&panel_config->area.pix.border, &a->pix.border, sizeof(Border));
}
+ /* Battery */
+ else if (strcmp (key, "battery") == 0) {
+ if(atoi(value) == 1)
+ panel_config->battery.area.on_screen = 1;
+ }
+ else if (strcmp (key, "battery_low_status") == 0) {
+ battery_low_status = atoi(value);
+ if(battery_low_status < 0 || battery_low_status > 100)
+ battery_low_status = 0;
+ }
+ else if (strcmp (key, "battery_low_cmd") == 0) {
+ if (battery_low_cmd) g_free(battery_low_cmd);
+ if (strlen(value) > 0) battery_low_cmd = strdup (value);
+ else battery_low_cmd = 0;
+ }
+ else if (strcmp (key, "bat1_font") == 0) {
+ if (save_file_config) old_bat1_font = strdup (value);
+ if (bat1_font_desc) pango_font_description_free(bat1_font_desc);
+ bat1_font_desc = pango_font_description_from_string (value);
+ }
+ else if (strcmp (key, "bat2_font") == 0) {
+ if (save_file_config) old_bat2_font = strdup (value);
+ if (bat2_font_desc) pango_font_description_free(bat2_font_desc);
+ bat2_font_desc = pango_font_description_from_string (value);
+ }
+ else if (strcmp (key, "battery_font_color") == 0) {
+ extract_values(value, &value1, &value2, &value3);
+ get_color (value1, panel_config->battery.font.color);
+ if (value2) panel_config->battery.font.alpha = (atoi (value2) / 100.0);
+ else panel_config->battery.font.alpha = 0.5;
+ }
+ else if (strcmp (key, "battery_padding") == 0) {
+ extract_values(value, &value1, &value2, &value3);
+ panel_config->battery.area.paddingxlr = panel_config->battery.area.paddingx = atoi (value1);
+ if (value2) panel_config->battery.area.paddingy = atoi (value2);
+ if (value3) panel_config->battery.area.paddingx = atoi (value3);
+ }
+ else if (strcmp (key, "battery_background_id") == 0) {
+ int id = atoi (value);
+ Area *a = g_slist_nth_data(list_back, id);
+ memcpy(&panel_config->battery.area.pix.back, &a->pix.back, sizeof(Color));
+ memcpy(&panel_config->battery.area.pix.border, &a->pix.border, sizeof(Border));
+ }
+
/* Clock */
else if (strcmp (key, "time1_format") == 0) {
if (time1_format) g_free(time1_format);
// clock and systray before taskbar because resize(clock) can resize others object ??
init_panel();
init_clock();
+ init_battery();
init_systray();
- init_taskbar();
- visible_object();
+ init_taskbar();
+ visible_object();
cleanup_config();
fputs("clock_padding = 2 2\n", fp);
fputs("clock_background_id = 0\n", fp);
+ fputs("\n#---------------------------------------------\n", fp);
+ fputs("# BATTERY\n", fp);
+ fputs("#---------------------------------------------\n", fp);
+ fprintf(fp, "battery = %d\n", panel_config->battery.area.on_screen);
+ fprintf(fp, "battery_low_status = %d\n", battery_low_status);
+ fprintf(fp, "battery_low_cmd = %s\n", battery_low_cmd);
+ fprintf(fp, "bat1_font = %s\n", old_bat1_font);
+ fprintf(fp, "bat2_font = %s\n", old_bat2_font);
+ fprintf(fp, "battery_font_color = #%02x%02x%02x %d\n", (int)(panel_config->battery.font.color[0]*255), (int)(panel_config->battery.font.color[1]*255), (int)(panel_config->battery.font.color[2]*255), (int)(panel_config->battery.font.alpha*100));
+ fputs("battery_padding = 2 2\n", fp);
+ fputs("battery_background_id = 0\n", fp);
+
fputs("\n#---------------------------------------------\n", fp);
fputs("# MOUSE ACTION ON TASK\n", fp);
fputs("#---------------------------------------------\n", fp);
// add childs
if (p->clock.area.on_screen)
p->area.list = g_slist_append(p->area.list, &p->clock);
+ if (p->battery.area.on_screen)
+ p->area.list = g_slist_append(p->area.list, &p->battery);
if (systray.area.on_screen && i == 0) {
// systray only on first panel
p->area.list = g_slist_append(p->area.list, &systray);
taskbar_width = panel->area.width - (2 * panel->area.paddingxlr) - (2 * panel->area.pix.border.width);
if (panel->clock.area.on_screen && panel->clock.area.width)
taskbar_width -= (panel->clock.area.width + panel->area.paddingx);
+ if (panel->battery.area.on_screen && panel->battery.area.width)
+ taskbar_width -= (panel->battery.area.width + panel->area.paddingx);
// TODO : systray only on first panel. search better implementation !
if (systray.area.on_screen && systray.area.width && panel == &panel1[0])
taskbar_width -= (systray.area.width + panel->area.paddingx);
#include <pango/pangocairo.h>
#include <sys/time.h>
+#include "battery.h"
#include "common.h"
#include "clock.h"
#include "task.h"
// clock
Clock clock;
+ // --------------------------------------------------
+ // battery
+ Battery battery;
+
} Panel;
systray.area.posx = panel->area.width - panel->area.paddingxlr - panel->area.pix.border.width - systray.area.width;
if (panel->clock.area.on_screen)
systray.area.posx -= (panel->clock.area.width + panel->area.paddingx);
+ if (panel->battery.area.on_screen)
+ systray.area.posx -= (panel->battery.area.width + panel->area.paddingx);
systray.area.redraw = 1;
}
systray.area.posx = panel->area.width - panel->area.pix.border.width - panel->area.paddingxlr - systray.area.width;
if (panel->clock.area.on_screen)
systray.area.posx -= (panel->clock.area.width + panel->area.paddingx);
+ if (panel->battery.area.on_screen)
+ systray.area.posx -= (panel->battery.area.width + panel->area.paddingx);
systray.area.redraw = 1;
if (time2_font_desc) pango_font_description_free(time2_font_desc);
if (time1_format) g_free(time1_format);
if (time2_format) g_free(time2_format);
+ if (battery_low_cmd) g_free(battery_low_cmd);
if (server.monitor) free(server.monitor);
XFreeGC(server.dsp, server.gc);
GSList *l0;
Taskbar *tskbar;
int x = e->xbutton.x;
- int y = e->xbutton.y;
+ //int y = e->xbutton.y; // unused
for (l0 = panel->area.list; l0 ; l0 = l0->next) {
tskbar = l0->data;
if (!tskbar->area.on_screen) continue;
int action = TOGGLE_ICONIFY;
int x = e->xbutton.x;
- int y = e->xbutton.y;
+ //int y = e->xbutton.y; // unused
switch (e->xbutton.button) {
case 2:
action = mouse_middle;
if (abs(stv.tv_sec - time_clock.tv_sec) < time_precision) return;
- // update clock
- time_clock.tv_sec = stv.tv_sec;
- time_clock.tv_sec -= time_clock.tv_sec % time_precision;
+ // update battery
+ update_battery(&battery_state);
+
+ // update clock
+ time_clock.tv_sec = stv.tv_sec;
+ time_clock.tv_sec -= time_clock.tv_sec % time_precision;
int i;
for (i=0 ; i < nb_panel ; i++) {
panel1[i].clock.area.resize = 1;
+ panel1[i].battery.area.resize = 1;
}
- panel_refresh = 1;
+ panel_refresh = 1;
}
clock_padding = 1 0
clock_background_id = 0
+#---------------------------------------------
+# BATTERY
+#---------------------------------------------
+battery = 0
+battery_low_status = 7
+battery_low_cmd = notify-send "battery low"
+bat1_font = sans 8
+bat2_font = sans 6
+battery_font_color = #ffffff 76
+battery_padding = 1 0
+battery_background_id = 0
+
+
#---------------------------------------------
# MOUSE ACTION ON TASK
#---------------------------------------------
clock_padding = 1 0
clock_background_id = 0
+#---------------------------------------------
+# BATTERY
+#---------------------------------------------
+battery = 1
+battery_low_status = 7
+battery_low_cmd = notify-send "battery low"
+bat1_font = sans 7
+bat2_font = sans 7
+battery_font_color = #ffffff 100
+battery_padding = 1 0
+battery_background_id = 0
+
#---------------------------------------------
# MOUSE ACTION ON TASK
#---------------------------------------------
clock_padding = 8 0
clock_background_id = 1
+#---------------------------------------------
+# BATTERY
+#---------------------------------------------
+battery = 0
+battery_low_status = 7
+battery_low_cmd = notify-send "battery low"
+bat1_font = sans 7
+bat2_font = sans 7
+battery_font_color = #ffffff 100
+battery_padding = 1 0
+battery_background_id = 0
+
#---------------------------------------------
# MOUSE ACTION ON TASK
#---------------------------------------------
clock_padding = 5 0
clock_background_id = 1
+#---------------------------------------------
+# BATTERY
+#---------------------------------------------
+battery = 0
+battery_low_status = 7
+battery_low_cmd = notify-send "battery low"
+bat1_font = sans 7
+bat2_font = sans 7
+battery_font_color = #ffffff 100
+battery_padding = 1 0
+battery_background_id = 0
+
#---------------------------------------------
# MOUSE ACTION ON TASK
#---------------------------------------------
clock_padding = 4 0
clock_background_id = 0
+#---------------------------------------------
+# BATTERY
+#---------------------------------------------
+battery = 1
+battery_low_status = 7
+battery_low_cmd = notify-send "battery low"
+bat1_font = sans 8
+bat2_font = sans 6
+battery_font_color = #ffffff 100
+battery_padding = 1 0
+battery_background_id = 0
+
#---------------------------------------------
# MOUSE ACTION ON TASK
#---------------------------------------------
clock_padding = 6 0
clock_background_id = 1
+#---------------------------------------------
+# BATTERY
+#---------------------------------------------
+battery = 0
+battery_low_status = 7
+battery_low_cmd = notify-send "battery low"
+bat1_font = sans 8
+bat2_font = sans 6
+battery_font_color = #ffffff 100
+battery_padding = 1 0
+battery_background_id = 0
+
#---------------------------------------------
# MOUSE ACTION ON TASK
#---------------------------------------------
clock_padding = 2 0
clock_background_id = 1
+#---------------------------------------------
+# BATTERY
+#---------------------------------------------
+battery = 1
+battery_low_status = 7
+battery_low_cmd = notify-send "battery low"
+bat1_font = sans bold 7
+bat2_font = sans 7
+battery_font_color = #ffffff 60
+battery_padding = 1 0
+battery_background_id = 1
+
#---------------------------------------------
# MOUSE ACTION ON TASK
#---------------------------------------------