clock_font_color = #151515 60
clock_padding = 4 0
clock_tooltip = %A %d %B
+clock_background_id = 1
#time1_timezone = :US/Hawaii
#time2_timezone = :Europe/Berlin
#clock_tooltip_timezone = :/usr/share/zoneinfo/Europe/Paris
fp = fopen(path_status, "r");
if(fp != NULL) {
- fgets(tmp, sizeof tmp, fp);
+ if (fgets(tmp, sizeof tmp, fp)) {
+ battery_state.state = BATTERY_UNKNOWN;
+ if(strcasecmp(tmp, "Charging\n")==0) battery_state.state = BATTERY_CHARGING;
+ if(strcasecmp(tmp, "Discharging\n")==0) battery_state.state = BATTERY_DISCHARGING;
+ if(strcasecmp(tmp, "Full\n")==0) battery_state.state = BATTERY_FULL;
+ }
fclose(fp);
}
- battery_state.state = BATTERY_UNKNOWN;
- if(strcasecmp(tmp, "Charging\n")==0) battery_state.state = BATTERY_CHARGING;
- if(strcasecmp(tmp, "Discharging\n")==0) battery_state.state = BATTERY_DISCHARGING;
- if(strcasecmp(tmp, "Full\n")==0) battery_state.state = BATTERY_FULL;
- if (battery_state.state == BATTERY_DISCHARGING) {
- }
- else {
- }
fp = fopen(path_energy_now, "r");
if(fp != NULL) {
- fgets(tmp, sizeof tmp, fp);
- energy_now = atoi(tmp);
+ if (fgets(tmp, sizeof tmp, fp)) energy_now = atoi(tmp);
fclose(fp);
}
fp = fopen(path_energy_full, "r");
if(fp != NULL) {
- fgets(tmp, sizeof tmp, fp);
- energy_full = atoi(tmp);
+ if (fgets(tmp, sizeof tmp, fp)) energy_full = atoi(tmp);
fclose(fp);
}
fp = fopen(path_current_now, "r");
if(fp != NULL) {
- fgets(tmp, sizeof tmp, fp);
- current_now = atoi(tmp);
+ if (fgets(tmp, sizeof tmp, fp)) current_now = atoi(tmp);
fclose(fp);
}
if(energy_full > 0)
new_percentage = (energy_now*100)/energy_full;
- if(battery_low_status > new_percentage && battery_state.state == BATTERY_DISCHARGING && !battery_low_cmd_send) {
- printf("battery low, executing: %s\n", battery_low_cmd);
- if (battery_low_cmd)
- system(battery_low_cmd);
- battery_low_cmd_send = 1;
+ if(battery_low_status > new_percentage && battery_state.state == BATTERY_DISCHARGING && !battery_low_cmd_send) {
+ if (battery_low_cmd)
+ if (-1 != system(battery_low_cmd))
+ battery_low_cmd_send = 1;
+ }
+ if(battery_low_status < new_percentage && battery_state.state == BATTERY_CHARGING && battery_low_cmd_send) {
+ battery_low_cmd_send = 0;
}
- if(battery_low_status < new_percentage && battery_state.state == BATTERY_CHARGING && battery_low_cmd_send) {
- battery_low_cmd_send = 0;
- }
battery_state.percentage = new_percentage;
pango_font_description_free(panel_config.g_task.font_desc);
panel_config.g_task.font_desc = 0;
}
+
+ if (backgrounds) {
+ g_array_free(backgrounds, 1);
+ backgrounds = 0;
+ }
}
server.atom._NET_SYSTEM_TRAY_ORIENTATION = XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_ORIENTATION", False);
server.atom._XEMBED = XInternAtom(server.dsp, "_XEMBED", False);
server.atom._XEMBED_INFO = XInternAtom(server.dsp, "_XEMBED_INFO", False);
+ g_free(name_trayer);
// drag 'n' drop
server.atom.XdndAware = XInternAtom(server.dsp, "XdndAware", False);
void cleanup_server()
{
- XFreeColormap(server.dsp, server.colormap);
- free(server.monitor);
- XFreeGC(server.dsp, server.gc);
+ if (server.colormap) XFreeColormap(server.dsp, server.colormap);
+ if (server.monitor) free(server.monitor);
+ if (server.gc) XFreeGC(server.dsp, server.gc);
}
// even with task_on_all_desktop and with task_on_all_panel
new_tsk.title = 0;
int k;
- for (k=0; k<TASK_STATE_COUNT; ++k)
+ for (k=0; k<TASK_STATE_COUNT; ++k) {
new_tsk.icon[k] = 0;
+ new_tsk.state_pix[k] = 0;
+ }
get_title(&new_tsk);
get_icon(&new_tsk);
if (snapshot_path) g_free(snapshot_path);
cleanup_server();
- XCloseDisplay(server.dsp);
+ if (server.dsp) XCloseDisplay(server.dsp);
}
default:
if (e.type == XDamageNotify+damage_event) {
+ // union needed to avoid strict-aliasing warnings by gcc
+ union { XEvent e; XDamageNotifyEvent de; } event_union = {.e=e};
TrayWindow *traywin;
GSList *l;
- XDamageNotifyEvent* de = (XDamageNotifyEvent*)&e;
+ XDamageNotifyEvent* de = &event_union.de;
for (l = systray.list_icons; l ; l = l->next) {
traywin = (TrayWindow*)l->data;
if ( traywin->id == de->drawable && !de->more ) {
fileDest = fopen(pathDest, "wb");
if (fileDest == NULL) return;
- while ((nb = fread(line, 1, 100, fileSrc)) > 0) fwrite(line, 1, nb, fileDest);
+ while ((nb = fread(line, 1, 100, fileSrc)) > 0)
+ if ( nb != fwrite(line, 1, nb, fileDest))
+ printf("Error while copying file %s to %s\n", pathSrc, pathDest);
fclose (fileDest);
fclose (fileSrc);
t1->multi_timeout = mt1;
t2->multi_timeout = mt2;
- real_timeout->multi_timeout = real_timeout;
+ // set real_timeout->multi_timeout to something, such that we see in add_timeout_intern that
+ // it is already a multi_timeout (we never use it, except of checking for 0 ptr)
+ real_timeout->multi_timeout = (void*)real_timeout;
timeout_list = g_slist_remove(timeout_list, t1);
timeout_list = g_slist_remove(timeout_list, t2);
multi_timeout_handler* mth = g_hash_table_lookup(multi_timeouts, t);
g_hash_table_remove(multi_timeouts, mth->parent_timeout);
while (mth->timeout_list) {
- timeout* t = mth->timeout_list->data;
- mth->timeout_list = g_slist_remove(mth->timeout_list, t);
- g_hash_table_remove(multi_timeouts, t);
- free(t);
+ timeout* t1 = mth->timeout_list->data;
+ mth->timeout_list = g_slist_remove(mth->timeout_list, t1);
+ g_hash_table_remove(multi_timeouts, t1);
+ free(t1->multi_timeout);
+ free(t1);
}
free(mth);
}