#include <unistd.h>
#include <string.h>
#include <errno.h>
+#include <pthread.h>
#include <string.h>
#include <limits.h>
#if HAVE_DIRENT_H
ERR("can't load font '%s'", fonts[i].name);
if ((fonts[i].font = XLoadQueryFont(display, "fixed")) == NULL) {
CRIT_ERR("can't load font '%s'", "fixed");
+ printf("loaded fixed?\n");
}
}
}
static long default_fg_color, default_bg_color, default_out_color;
/* create own window or draw stuff to root? */
-static int own_window = 0;
+static int set_transparent = 0;
+
#ifdef OWN_WINDOW
+static int own_window = 0;
+static int background_colour = 0;
/* fixed size/pos is set if wm/user changes them */
static int fixed_size = 0, fixed_pos = 0;
#endif
static int minimum_width, minimum_height;
+static int maximum_width;
/* UTF-8 */
int utf8_mode = 0;
"$hr\n"
"${color grey}Uptime:$color $uptime\n"
"${color grey}Frequency (in MHz):$color $freq\n"
- "${color grey}Frequency (in Ghz):$color $freq_g\n"
+ "${color grey}Frequency (in GHz):$color $freq_g\n"
"${color grey}RAM Usage:$color $mem/$memmax - $memperc% ${membar 4}\n"
"${color grey}Swap Usage:$color $swap/$swapmax - $swapperc% ${swapbar 4}\n"
"${color grey}CPU Usage:$color $cpu% ${cpubar 4}\n"
static int special_index; /* used when drawing */
#endif /* X11 */
-#define MAX_GRAPH_DEPTH 256 /* why 256? who knows. */
+#define MAX_GRAPH_DEPTH 256 /* why 256? cause an array of more then 256 doubles seems excessive, and who needs that kind of precision anyway? */
static struct special_t *new_special(char *buf, int t)
{
buf[0] = SPECIAL_CHAR;
buf[1] = '\0';
- if (t == GRAPH && specials[special_count].graph == NULL) {
- if (specials[special_count].width > 0
- && specials[special_count].width < MAX_GRAPH_DEPTH)
- specials[special_count].graph_width = specials[special_count].width - 3; // subtract 3 for the box
- else
- specials[special_count].graph_width =
- MAX_GRAPH_DEPTH;
- specials[special_count].graph =
- calloc(specials[special_count].graph_width,
- sizeof(double));
- specials[special_count].graph_scale = 100;
- }
specials[special_count].type = t;
return &specials[special_count++];
}
int tmp = selected_font;
selected_font = s->font_added = addfont(args);
load_fonts();
- set_font();
+// set_font();
selected_font = tmp;
}
}
inline void graph_append(struct special_t *graph, double f)
{
+ if (!graph->scaled && f > graph->graph_scale) {
+ f = graph->graph_scale;
+ }
int i;
if (graph->scaled) {
- graph->graph_scale = 0;
+ graph->graph_scale = 1;
}
graph->graph[graph->graph_width - 1] = f; /* add new data */
for (i = 0; i < graph->graph_width - 1; i++) { /* shift all the data by 1 */
}
}
-static void new_graph(char *buf, int w, int h, unsigned int first_colour, unsigned int second_colour, double i, int scaled, int append)
+short colour_depth = 0;
+void set_up_gradient();
+
+/* precalculated: 31/255, and 63/255 */
+#define CONST_8_TO_5_BITS 0.12156862745098
+#define CONST_8_TO_6_BITS 0.247058823529412
+
+/* adjust color values depending on color depth*/
+static unsigned int adjust_colors(unsigned int color)
+{
+ double r, g, b;
+ if (colour_depth == 0) {
+ set_up_gradient();
+ }
+ if (colour_depth == 16) {
+ r = (color & 0xff0000) >> 16;
+ g = (color & 0xff00) >> 8;
+ b = color & 0xff;
+ color = (int)(r * CONST_8_TO_5_BITS) << 11;
+ color |= (int)(g * CONST_8_TO_6_BITS) << 5;
+ color |= (int)(b * CONST_8_TO_5_BITS);
+ }
+ return color;
+}
+
+static void new_graph(char *buf, int w, int h, unsigned int first_colour, unsigned int second_colour, double i, int scale, int append)
{
struct special_t *s = new_special(buf, GRAPH);
s->width = w;
+ if (s->graph == NULL) {
+ if (s->width > 0 && s->width < MAX_GRAPH_DEPTH) {
+ s->graph_width = s->width - 3; // subtract 3 for the box
+ } else {
+ s->graph_width = MAX_GRAPH_DEPTH - 3;
+ }
+ s->graph = malloc(s->graph_width * sizeof(double));
+ memset(s->graph, 0, s->graph_width * sizeof(double));
+ s->graph_scale = 100;
+ }
s->height = h;
- s->first_colour = first_colour;
- s->last_colour = second_colour;
- s->scaled = scaled;
- if (s->width) {
- s->graph_width = s->width - 3; // subtract 3 for rectangle around
+ s->first_colour = adjust_colors(first_colour);
+ s->last_colour = adjust_colors(second_colour);
+ if (scale != 0) {
+ s->scaled = 0;
+ } else {
+ s->scaled = 1;
}
- if (scaled) {
+ /*if (s->width) {
+ s->graph_width = s->width - 3; // subtract 3 for rectangle around
+ }*/
+ if (s->scaled) {
s->graph_scale = 1;
} else {
- s->graph_scale = 100;
+ s->graph_scale = scale;
}
if (append) {
graph_append(s, i);
}
}
-static const char *scan_graph(const char *args, int *w, int *h, unsigned int *first_colour, unsigned int *last_colour)
+static const char *scan_graph(const char *args, int *w, int *h, unsigned int *first_colour, unsigned int *last_colour, unsigned int *scale)
{
*w = 0; /* zero width means all space that is available */
*h = 25;
*last_colour = 0;
/* graph's argument is either height or height,width */
if (args) {
- if (sscanf(args, "%*s %d,%d %x %x", h, w, first_colour, last_colour) < 4) {
- if (sscanf(args, "%d,%d %x %x", h, w, first_colour, last_colour) < 4) {
- *w = 0;
+ if (sscanf(args, "%*s %d,%d %x %x %i", h, w, first_colour, last_colour, scale) < 5) {
+ if (sscanf(args, "%*s %d,%d %x %x", h, w, first_colour, last_colour) < 4) {
+ *scale = 0;
+ if (sscanf(args, "%d,%d %x %x %i", h, w, first_colour, last_colour, scale) < 5) {
+ *scale = 0;
+ if (sscanf(args, "%d,%d %x %x", h, w, first_colour, last_colour) < 4) {
+ *w = 0;
*h = 25;
- if (sscanf(args, "%*s %x %x", first_colour, last_colour) < 3) {
+ if (sscanf(args, "%*s %x %x %i", first_colour, last_colour, scale) < 3) {
*w = 0;
*h = 25;
- if (sscanf(args, "%x %x", first_colour, last_colour) < 2) {
+ *scale = 0;
+ if (sscanf(args, "%*s %x %x", first_colour, last_colour) < 2) {
+ *w = 0;
+ *h = 25;
+ if (sscanf(args, "%x %x %i", first_colour, last_colour, scale) < 3) {
+ *first_colour = 0;
+ *last_colour = 0;
+ *scale = 0;
+ if (sscanf(args, "%x %x", first_colour, last_colour) < 2) {
*first_colour = 0;
*last_colour = 0;
- if (sscanf(args, "%d,%d", h, w) < 2) {
+ if (sscanf(args, "%d,%d %i", h, w, scale) < 3) {
*first_colour = 0;
*last_colour = 0;
- sscanf(args, "%*s %d,%d", h, w);
- }
- }
- }
- }
- }
- }
-
+ *scale = 0;
+ if (sscanf(args, "%d,%d", h, w) < 2) {
+ *first_colour = 0;
+ *last_colour = 0;
+ sscanf(args, "%*s %d,%d", h, w);
+ }}}}}}}}}}} // haha
return args;
}
/* converts from bytes to human readable format (k, M, G, T) */
static void human_readable(long long a, char *buf, int size)
{
- //Strange conditional due to possible overflows
+ // Strange conditional due to possible overflows
if(a / 1024 / 1024 / 1024.0 > 1024.0){
- snprintf(buf, size, "%.2fT", (a / 1024 / 1024) / 1024 / 1024.0);
+ snprintf(buf, size, "%.2fT", (a / 1024 / 1024 / 1024) / 1024.0);
}
else if (a >= 1024 * 1024 * 1024) {
snprintf(buf, size, "%.2fG", (a / 1024 / 1024) / 1024.0);
OBJ_cpu,
OBJ_cpubar,
OBJ_cpugraph,
+ OBJ_diskio,
+ OBJ_diskiograph,
OBJ_downspeed,
OBJ_downspeedf,
OBJ_downspeedgraph,
OBJ_endif,
OBJ_exec,
OBJ_execi,
+ OBJ_texeci,
OBJ_execbar,
OBJ_execgraph,
OBJ_execibar,
OBJ_execigraph,
OBJ_freq,
OBJ_freq_g,
+ OBJ_freq_dyn,
+ OBJ_freq_dyn_g,
OBJ_fs_bar,
OBJ_fs_bar_free,
OBJ_fs_free,
OBJ_alignr,
OBJ_alignc,
OBJ_i2c,
+#if defined(__linux__)
+ OBJ_i8k_version,
+ OBJ_i8k_bios,
+ OBJ_i8k_serial,
+ OBJ_i8k_cpu_temp,
+ OBJ_i8k_cpu_tempf,
+ OBJ_i8k_left_fan_status,
+ OBJ_i8k_right_fan_status,
+ OBJ_i8k_left_fan_rpm,
+ OBJ_i8k_right_fan_rpm,
+ OBJ_i8k_ac_status,
+ OBJ_i8k_buttons_status,
+#endif /* __linux__ */
OBJ_if_existing,
OBJ_if_mounted,
OBJ_if_running,
OBJ_top,
OBJ_top_mem,
OBJ_tail,
+ OBJ_head,
OBJ_kernel,
OBJ_loadavg,
OBJ_machine,
OBJ_upspeedgraph,
OBJ_uptime,
OBJ_uptime_short,
+#ifdef __FreeBSD__
+ OBJ_apm_adapter,
+ OBJ_apm_battery_time,
+ OBJ_apm_battery_life,
+#endif /* __FreeBSD__ */
#ifdef SETI
OBJ_seti_prog,
OBJ_seti_progbar,
struct text_object {
int type;
int a, b;
- unsigned int c, d;
+ unsigned int c, d, e;
+ float f;
union {
char *s; /* some string */
int i; /* some integer */
struct net_stat *net;
struct fs_stat *fs;
unsigned char loadavg[3];
-
+ //unsigned int diskio;
+ unsigned int cpu_index;
struct {
struct fs_stat *fs;
int w, h;
static unsigned int text_object_count;
static struct text_object *text_objects;
+pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
+
+void *threaded_exec( struct text_object *obj ) {
+ char *p2 = obj->data.execi.buffer;
+ FILE *fp = popen(obj->data.execi.cmd,"r");
+ pthread_mutex_lock( &mutex1 );
+ int n2 = fread(p2, 1, TEXT_BUFFER_SIZE, fp);
+ (void) pclose(fp);
+ p2[n2] = '\0';
+ if (n2 && p2[n2 - 1] == '\n')
+ p2[n2 - 1] = '\0';
+
+ while (*p2) {
+ if (*p2 == '\001')
+ *p2 = ' ';
+ p2++;
+ }
+ pthread_mutex_unlock( &mutex1 );
+ return NULL;
+}
+
/* new_text_object() allocates a new zeroed text_object */
static struct text_object *new_text_object()
{
free(text_objects[i].data.ifblock.s);
break;
case OBJ_text:
+ case OBJ_font:
+ free(text_objects[i].data.s);
+ break;
case OBJ_exec:
free(text_objects[i].data.s);
break;
free(text_objects[i].data.execi.cmd);
free(text_objects[i].data.execi.buffer);
break;
+ case OBJ_texeci:
+ free(text_objects[i].data.execi.cmd);
+ free(text_objects[i].data.execi.buffer);
+ break;
}
}
END OBJ(acpiacadapter, 0)
END OBJ(freq, 0);
END OBJ(freq_g, 0);
+ END OBJ(freq_dyn, 0);
+ END OBJ(freq_dyn_g, 0);
END OBJ(acpifan, 0);
END OBJ(battery, 0);
char bat[64];
else
strcpy(bat, "BAT0");
obj->data.s = strdup(bat);
+#if defined(__linux__)
+ END OBJ(i8k_version, INFO_I8K)
+ END OBJ(i8k_bios, INFO_I8K)
+ END OBJ(i8k_serial, INFO_I8K)
+ END OBJ(i8k_cpu_temp, INFO_I8K)
+ END OBJ(i8k_cpu_tempf, INFO_I8K)
+ END OBJ(i8k_left_fan_status, INFO_I8K)
+ END OBJ(i8k_right_fan_status, INFO_I8K)
+ END OBJ(i8k_left_fan_rpm, INFO_I8K)
+ END OBJ(i8k_right_fan_rpm, INFO_I8K)
+ END OBJ(i8k_ac_status, INFO_I8K)
+ END OBJ(i8k_buttons_status, INFO_I8K)
+#endif /* __linux__ */
END OBJ(buffers, INFO_BUFFERS)
END OBJ(cached, INFO_BUFFERS)
END OBJ(cpu, INFO_CPU)
+ if (arg) {
+ if (strncmp(arg, "cpu", 3) == 0 && isdigit(arg[3])) {
+ obj->data.cpu_index = atoi(&arg[3]);
+ arg += 4;
+ } else {obj->data.cpu_index = 0; }
+ } else {
+ obj->data.cpu_index = 0;
+ }
END OBJ(cpubar, INFO_CPU)
- (void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
+ if (arg) {
+ if (strncmp(arg, "cpu", 3) == 0 && isdigit(arg[3])) {
+ obj->data.cpu_index = atoi(&arg[3]);
+ arg += 4;
+ }
+ else {obj->data.cpu_index = 0;}
+ (void) scan_bar(arg, &obj->a, &obj->b);
+ } else {
+ (void) scan_bar(arg, &obj->a, &obj->b);
+ obj->data.cpu_index = 0;
+ }
END OBJ(cpugraph, INFO_CPU)
- (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d);
+ if (arg) {
+ if (strncmp(arg, "cpu", 3) == 0 && isdigit(arg[3])) {
+ obj->data.cpu_index = atoi(&arg[3]);
+ arg += 4;
+ }
+ (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
+ } else {
+ (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
+ obj->data.cpu_index = 0;
+ }
+ END OBJ(diskio, INFO_DISKIO)
+ END OBJ(diskiograph, INFO_DISKIO) (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
END OBJ(color, 0)
#ifdef X11
obj->data.l = arg ? get_x11_color(arg) : default_fg_color;
#endif /* X11 */
END
- OBJ(font, 0)
+ OBJ(font, 0)
obj->data.s = scan_font(arg);
- END
- OBJ(downspeed, INFO_NET) obj->data.net = get_net_stat(arg);
- END OBJ(downspeedf, INFO_NET) obj->data.net = get_net_stat(arg);
+ END
+ OBJ(downspeed, INFO_NET)
+ if(arg) {
+ obj->data.net = get_net_stat(arg);
+ }
+ else {
+ CRIT_ERR("downspeed needs argument");
+ }
+ END OBJ(downspeedf, INFO_NET)
+ if(arg) {
+ obj->data.net = get_net_stat(arg);
+ }
+ else {
+ CRIT_ERR("downspeedf needs argument");
+ }
END OBJ(downspeedgraph, INFO_NET)
- (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d);
+ (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
char buf[64];
sscanf(arg, "%63s %*i,%*i %*i", buf);
obj->data.net = get_net_stat(buf);
snprintf(buf, 256, "${%s}", s);
obj->data.s = strdup(buf);
} else {
- obj->data.s = strdup(arg + n);
+ obj->data.execi.cmd = strdup(arg + n);
}
END OBJ(execigraph, 0) unsigned int n;
if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
snprintf(buf, 256, "${%s}", s);
obj->data.s = strdup(buf);
} else {
- obj->data.s = strdup(arg + n);
+ obj->data.execi.cmd = strdup(arg + n);
}
END OBJ(execi, 0) unsigned int n;
obj->data.execi.buffer =
(char *) calloc(1, TEXT_BUFFER_SIZE);
}
+ END OBJ(texeci, 0) unsigned int n;
+
+ if (!arg
+ || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
+ char buf[256];
+ ERR("${texeci <interval> command}");
+ obj->type = OBJ_text;
+ snprintf(buf, 256, "${%s}", s);
+ obj->data.s = strdup(buf);
+ } else {
+ obj->data.execi.cmd = strdup(arg + n);
+ obj->data.execi.buffer =
+ (char *) calloc(1, TEXT_BUFFER_SIZE);
+ }
END OBJ(pre_exec, 0) obj->type = OBJ_text;
if (arg) {
FILE *fp = popen(arg, "r");
if (!arg) {
ERR("i2c needs arguments");
obj->type = OBJ_text;
- obj->data.s = strdup("${i2c}");
+ //obj->data.s = strdup("${i2c}");
return;
}
obj->data.i2c.fd =
open_i2c_sensor(0, buf2, n, &obj->data.i2c.arg,
obj->data.i2c.devtype);
- strcpy(obj->data.i2c.type, buf2);
+ strncpy(obj->data.i2c.type, buf2, 63);
} else {
obj->data.i2c.fd =
open_i2c_sensor(buf1, buf2, n, &obj->data.i2c.arg,
obj->data.i2c.devtype);
- strcpy(obj->data.i2c.type, buf2);
+ strncpy(obj->data.i2c.type, buf2, 63);
}
END OBJ(top, INFO_TOP)
if (!arg) {
ERR("top needs arguments");
obj->type = OBJ_text;
- obj->data.s = strdup("${top}");
+ //obj->data.s = strdup("${top}");
return;
}
if (sscanf(arg, "%63s %i", buf, &n) == 2) {
ERR("invalid args given for top");
return;
}
- END OBJ(addr, INFO_NET) obj->data.net = get_net_stat(arg);
- END OBJ(linkstatus, INFO_WIFI) obj->data.net = get_net_stat(arg);
+ END OBJ(addr, INFO_NET)
+ if(arg) {
+ obj->data.net = get_net_stat(arg);
+ }
+ else {
+ CRIT_ERR("addr needs argument");
+ }
+ END OBJ(linkstatus, INFO_WIFI)
+ if(arg) {
+ obj->data.net = get_net_stat(arg);
+ }
+ else {
+ CRIT_ERR("linkstatus needs argument");
+ }
END OBJ(tail, 0)
char buf[64];
int n1, n2;
ERR("invalid args given for tail");
return;
}
- obj->data.tail.buffer = malloc(TEXT_BUFFER_SIZE * 6); /* asumming all else worked */
+ obj->data.tail.buffer = malloc(TEXT_BUFFER_SIZE * 20); /* asumming all else worked */
+ END OBJ(head, 0)
+ char buf[64];
+ int n1, n2;
+ if (!arg) {
+ ERR("head needs arguments");
+ obj->type = OBJ_text;
+ obj->data.s = strdup("${head}");
+ return;
+ }
+ if (sscanf(arg, "%63s %i %i", buf, &n1, &n2) == 2) {
+ if (n1 < 1 || n1 > 30) {
+ CRIT_ERR("invalid arg for head, number of lines must be between 1 and 30");
+ return;
+ } else {
+ FILE *fp;
+ fp = fopen(buf, "rt");
+ if (fp != NULL) {
+ obj->data.tail.logfile =
+ malloc(TEXT_BUFFER_SIZE);
+ strcpy(obj->data.tail.logfile, buf);
+ obj->data.tail.wantedlines = n1 - 1;
+ obj->data.tail.interval =
+ update_interval * 2;
+ fclose(fp);
+ } else {
+ //fclose (fp);
+ CRIT_ERR("head logfile does not exist, or you do not have correct permissions");
+ }
+ }
+ } else if (sscanf(arg, "%63s %i %i", buf, &n1, &n2) == 3) {
+ if (n1 < 1 || n1 > 30) {
+ CRIT_ERR
+ ("invalid arg for head, number of lines must be between 1 and 30");
+ return;
+ } else if (n2 < 1 || n2 < update_interval) {
+ CRIT_ERR
+ ("invalid arg for head, interval must be greater than 0 and Conky's interval");
+ return;
+ } else {
+ FILE *fp;
+ fp = fopen(buf, "rt");
+ if (fp != NULL) {
+ obj->data.tail.logfile =
+ malloc(TEXT_BUFFER_SIZE);
+ strcpy(obj->data.tail.logfile, buf);
+ obj->data.tail.wantedlines = n1 - 1;
+ obj->data.tail.interval = n2;
+ fclose(fp);
+ } else {
+ //fclose (fp);
+ CRIT_ERR("head logfile does not exist, or you do not have correct permissions");
+ }
+ }
+ }
+
+ else {
+ ERR("invalid args given for head");
+ return;
+ }
+ obj->data.tail.buffer = malloc(TEXT_BUFFER_SIZE * 20); /* asumming all else worked */
END OBJ(loadavg, INFO_LOADAVG) int a = 1, b = 2, c = 3, r = 3;
if (arg) {
r = sscanf(arg, "%d %d %d", &a, &b, &c);
END OBJ(membar, INFO_MEM)
(void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
END OBJ(memgraph, INFO_MEM)
- (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d);
+ (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
END OBJ(mixer, INFO_MIXER) obj->data.l = mixer_init(arg);
END OBJ(mixerl, INFO_MIXER) obj->data.l = mixer_init(arg);
END OBJ(mixerr, INFO_MIXER) obj->data.l = mixer_init(arg);
obj->data.i2c.devtype);
END OBJ(time, 0) obj->data.s = strdup(arg ? arg : "%F %T");
END OBJ(utime, 0) obj->data.s = strdup(arg ? arg : "%F %T");
- END OBJ(totaldown, INFO_NET) obj->data.net = get_net_stat(arg);
+ END OBJ(totaldown, INFO_NET)
+ if(arg) {
+ obj->data.net = get_net_stat(arg);
+ }
+ else {
+ CRIT_ERR("totaldown needs argument");
+ }
END OBJ(totalup, INFO_NET) obj->data.net = get_net_stat(arg);
+ if(arg) {
+ obj->data.net = get_net_stat(arg);
+ }
+ else {
+ CRIT_ERR("totalup needs argument");
+ }
END OBJ(updates, 0)
END OBJ(alignr, 0) obj->data.i = arg ? atoi(arg) : 0;
END OBJ(alignc, 0) obj->data.i = arg ? atoi(arg) : 0;
- END OBJ(upspeed, INFO_NET) obj->data.net = get_net_stat(arg);
- END OBJ(upspeedf, INFO_NET) obj->data.net = get_net_stat(arg);
+ END OBJ(upspeed, INFO_NET)
+ if(arg) {
+ obj->data.net = get_net_stat(arg);
+ }
+ else {
+ CRIT_ERR("upspeed needs argument");
+ }
+ END OBJ(upspeedf, INFO_NET)
+ if(arg) {
+ obj->data.net = get_net_stat(arg);
+ }
+ else {
+ CRIT_ERR("upspeedf needs argument");
+ }
+
END OBJ(upspeedgraph, INFO_NET)
- (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d);
+ (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
char buf[64];
sscanf(arg, "%63s %*i,%*i %*i", buf);
obj->data.net = get_net_stat(buf);
}
END OBJ(uptime_short, INFO_UPTIME) END OBJ(uptime, INFO_UPTIME) END
OBJ(adt746xcpu, 0) END OBJ(adt746xfan, 0) END
+#ifdef __FreeBSD__
+ OBJ(apm_adapter, 0) END
+ OBJ(apm_battery_life, 0) END
+ OBJ(apm_battery_time, 0) END
+#endif /* __FreeBSD__ */
#ifdef SETI
OBJ(seti_prog, INFO_SETI) END OBJ(seti_progbar, INFO_SETI)
(void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
i)+ 40) * 9.0 / 5 - 40));
}
OBJ(freq) {
- snprintf(p, n, "%sMhz", get_freq());
+ snprintf(p, n, "%.0f", get_freq());
}
OBJ(freq_g) {
- float ghz = (float)(atof(get_freq())/1000);
+ float ghz = (float)(get_freq()/1000);
//printf("%f\n", ghz);
- snprintf(p, n, "%'.2fGhz", ghz);
+ snprintf(p, n, "%'.2f", ghz);
+ }
+ OBJ(freq_dyn) {
+ snprintf(p, n, "%.0f", get_freq_dynamic());
+ }
+ OBJ(freq_dyn_g) {
+ float ghz = (float)(get_freq_dynamic()/1000);
+ snprintf(p, n, "%'.2f", ghz);
}
OBJ(adt746xcpu) {
snprintf(p, n, "%s", get_adt746x_cpu());
human_readable(cur->cached * 1024, p, 255);
}
OBJ(cpu) {
+ if (obj->data.cpu_index > info.cpu_count) {
+ printf("obj->data.cpu_index %i info.cpu_count %i", obj->data.cpu_index, info.cpu_count);
+ CRIT_ERR("attempting to use more CPUs then you have!");
+ }
if (!use_spacer)
snprintf(p, n, "%*d", pad_percents,
- (int) (cur->cpu_usage *
+ (int) round_to_int(cur->cpu_usage[obj->data.cpu_index] *
100.0));
else
snprintf(p, 4, "%*d ",
pad_percents,
- (int) (cur->cpu_usage *
+ (int) round_to_int(cur->cpu_usage[obj->data.cpu_index] *
100.0));
}
OBJ(cpubar) {
- new_bar(p, obj->data.pair.a,
- obj->data.pair.b,
- (int) (cur->cpu_usage * 255.0));
+ new_bar(p, obj->a,
+ obj->b,
+ (int) round_to_int(cur->cpu_usage[obj->data.cpu_index] * 255.0));
}
OBJ(cpugraph) {
new_graph(p, obj->a,
obj->b, obj->c, obj->d,
- (unsigned int) (cur->cpu_usage *
- 100), 0, 1);
+ (unsigned int) round_to_int(cur->cpu_usage[obj->data.cpu_index] *
+ 100), 100, 1);
}
OBJ(color) {
new_fg(p, obj->data.l);
}
+#if defined(__linux__)
+ OBJ(i8k_version) {
+ snprintf(p, n, "%s", i8k.version);
+ }
+ OBJ(i8k_bios) {
+ snprintf(p, n, "%s", i8k.bios);
+ }
+ OBJ(i8k_serial) {
+ snprintf(p, n, "%s", i8k.serial);
+ }
+ OBJ(i8k_cpu_temp) {
+ snprintf(p, n, "%s", i8k.cpu_temp);
+ }
+ OBJ(i8k_cpu_tempf) {
+ int cpu_temp;
+ sscanf(i8k.cpu_temp, "%d", &cpu_temp);
+ snprintf(p, n, "%.1f", cpu_temp*(9.0/5.0)+32.0);
+ }
+ OBJ(i8k_left_fan_status) {
+ int left_fan_status;
+ sscanf(i8k.left_fan_status, "%d", &left_fan_status);
+ if(left_fan_status == 0) {
+ snprintf(p, n,"off");
+ } if(left_fan_status == 1) {
+ snprintf(p, n, "low");
+ } if(left_fan_status == 2) {
+ snprintf(p, n, "high");
+ }
+
+ }
+ OBJ(i8k_right_fan_status) {
+ int right_fan_status;
+ sscanf(i8k.right_fan_status, "%d", &right_fan_status);
+ if(right_fan_status == 0) {
+ snprintf(p, n,"off");
+ } if(right_fan_status == 1) {
+ snprintf(p, n, "low");
+ } if(right_fan_status == 2) {
+ snprintf(p, n, "high");
+ }
+ }
+ OBJ(i8k_left_fan_rpm) {
+ snprintf(p, n, "%s", i8k.left_fan_rpm);
+ }
+ OBJ(i8k_right_fan_rpm) {
+ snprintf(p, n, "%s", i8k.right_fan_rpm);
+ }
+ OBJ(i8k_ac_status) {
+ int ac_status;
+ sscanf(i8k.ac_status, "%d", &ac_status);
+ if(ac_status == -1) {
+ snprintf(p, n,"disabled (read i8k docs)");
+ } if(ac_status == 0) {
+ snprintf(p, n, "off");
+ } if(ac_status == 1) {
+ snprintf(p, n, "on");
+ }
+ }
+ OBJ(i8k_buttons_status) {
+ snprintf(p, n, "%s", i8k.buttons_status);
+
+ }
+#endif /* __linux__ */
+
#ifdef X11
OBJ(font) {
new_font(p, obj->data.s);
}
#endif /* X11 */
+ OBJ(diskio) {
+ if (!use_spacer) {
+ if (diskio_value > 1024*1024) {
+ snprintf(p, n, "%.1fG",
+ (double)diskio_value/1024/1024);
+ } else if (diskio_value > 1024) {
+ snprintf(p, n, "%.1fM",
+ (double)diskio_value/1024);
+ } else if (diskio_value > 0) {
+ snprintf(p, n, "%dK", diskio_value);
+ } else {
+ snprintf(p, n, "%d", diskio_value);
+ }
+ } else {
+ if (diskio_value > 1024*1024) {
+ snprintf(p, 6, "%.1fG ",
+ (double)diskio_value/1024/1024);
+ } else if (diskio_value > 1024) {
+ snprintf(p, 6, "%.1fM ",
+ (double)diskio_value/1024);
+ } else if (diskio_value > 0) {
+ snprintf(p, 6, "%dK ", diskio_value);
+ } else {
+ snprintf(p, 6, "%d ", diskio_value);
+ }
+ }
+ }
+ OBJ(diskiograph) {
+ new_graph(p, obj->a,
+ obj->b, obj->c, obj->d,
+ diskio_value, obj->e, 1);
+ }
+
OBJ(downspeed) {
if (!use_spacer) {
snprintf(p, n, "%d",
obj->data.net->recv_speed = 0.01;
new_graph(p, obj->a, obj->b, obj->c, obj->d,
(obj->data.net->recv_speed /
- 1024.0), 1, 1);
+ 1024.0), obj->e, 1);
}
OBJ(
else
ERR("your execgraph value is not between 0 and 100, therefore it will be ignored");
} else {
new_graph(p, 0,
- 25, obj->c, obj->d, (int) (barnum), 0, 1);
+ 25, obj->c, obj->d, (int) (barnum), obj->e, 1);
}
}
OBJ(execibar) {
if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
- new_bar(p, 0, 4, (int) obj->data.execi.data);
+ new_bar(p, 0, 4, (int) obj->f);
} else {
char *p2 = p;
- FILE *fp = popen(obj->data.s, "r");
+ FILE *fp = popen(obj->data.execi.cmd, "r");
int n2 = fread(p, 1, n, fp);
(void) pclose(fp);
p[n2] = '\0';
*p2 = ' ';
p2++;
}
- double barnum;
- if (sscanf(p, "%lf", &barnum) == 0) {
+ float barnum;
+ if (sscanf(p, "%f", &barnum) == 0) {
ERR("reading execibar value failed (perhaps it's not the correct format?)");
}
if (barnum > 100 || barnum < 0) {
ERR("your execibar value is not between 0 and 100, therefore it will be ignored");
} else {
- obj->data.execi.data = 255 * barnum / 100.0;
- new_bar(p, 0, 4, (int) obj->data.execi.data);
+ obj->f = 255 * barnum / 100.0;
+ new_bar(p, 0, 4, (int) obj->f);
}
obj->data.execi.last_update =
current_update_time;
}
OBJ(execigraph) {
if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
- new_graph(p, 0, 25, obj->c, obj->d, (int) (obj->data.execi.data), 0, 0);
+ new_graph(p, 0, 25, obj->c, obj->d, (int) (obj->f), 100, 0);
} else {
char *p2 = p;
- FILE *fp = popen(obj->data.s, "r");
+ FILE *fp = popen(obj->data.execi.cmd, "r");
int n2 = fread(p, 1, n, fp);
(void) pclose(fp);
p[n2] = '\0';
*p2 = ' ';
p2++;
}
- double barnum;
- if (sscanf(p, "%lf", &barnum) == 0) {
+ float barnum;
+ if (sscanf(p, "%f", &barnum) == 0) {
ERR("reading execigraph value failed (perhaps it's not the correct format?)");
}
if (barnum > 100 || barnum < 0) {
ERR("your execigraph value is not between 0 and 100, therefore it will be ignored");
} else {
- obj->data.execi.data = barnum;
- new_graph(p, 0, 25, obj->c, obj->d, (int) (obj->data.execi.data), 0, 1);
+ obj->f = barnum;
+ new_graph(p, 0, 25, obj->c, obj->d, (int) (obj->f), 100, 1);
}
obj->data.execi.last_update = current_update_time;
current_update_time;
}
}
+ OBJ(texeci) {
+ static int running = 0;
+ if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
+ snprintf(p, n, "%s", obj->data.execi.buffer);
+ } else {
+ static pthread_t execthread;
+ if (!running) {
+ running = 1;
+ pthread_create( &execthread, NULL, (void*)threaded_exec, (void*) obj);
+ pthread_mutex_lock( &mutex1 );
+ obj->data.execi.last_update = current_update_time;
+ pthread_mutex_unlock( &mutex1 );
+ } else {
+ pthread_join( execthread, NULL);
+ running = 0;
+ }
+ snprintf(p, n, "%s", obj->data.execi.buffer);
+ }
+ }
#endif
OBJ(fs_bar) {
if (obj->data.fs != NULL) {
new_graph(p, obj->a,
obj->b, obj->c, obj->d,
cur->memmax ? (cur->mem * 100.0) /
- (cur->memmax) : 0.0, 0, 1);
+ (cur->memmax) : 0.0, 100, 1);
}
/* mixer stuff */
OBJ(mixer) {
obj->data.net->trans_speed = 0.01;
new_graph(p, obj->a, obj->b, obj->c, obj->d,
(obj->data.net->trans_speed /
- 1024.0), 1, 1);
+ 1024.0), obj->e, 1);
}
OBJ(uptime_short) {
format_seconds_short(p, n,
format_seconds(p, n, (int) cur->uptime);
}
+#ifdef __FreeBSD__
+ OBJ(apm_adapter) {
+ snprintf(p, n, "%s", get_apm_adapter());
+ }
+ OBJ(apm_battery_life) {
+ char *msg;
+ msg = get_apm_battery_life();
+ snprintf(p, n, "%s", msg);
+ free(msg);
+ }
+ OBJ(apm_battery_time) {
+ char *msg;
+ msg = get_apm_battery_time();
+ snprintf(p, n, "%s", msg);
+ free(msg);
+ }
+#endif /* __FreeBSD__ */
#ifdef SETI
OBJ(seti_prog) {
snprintf(p, n, "%.2f",
}
seconds = tmp;
if (days > 0)
- snprintf(p, n, "%i days %i:%i:%2i",
+ snprintf(p, n, "%i days %i:%02i:%02i",
days, hours, minutes,
seconds);
- else if (days > 0)
- snprintf(p, n, "%i:%i:%02i", hours,
+ else if (hours > 0)
+ snprintf(p, n, "%i:%02i:%02i", hours,
minutes, seconds);
else
snprintf(p, n, "%i:%02i", minutes,
seconds = tmp;
if (days > 0)
snprintf(p, n,
- "%i days %i:%i:%02i",
+ "%i days %i:%02i:%02i",
days, hours, minutes,
seconds);
- else if (days > 0)
- snprintf(p, n, "%i:%i:%02i", hours,
+ else if (hours > 0)
+ snprintf(p, n, "%i:%02i:%02i", hours,
minutes, seconds);
else
snprintf(p, n, "%i:%02i", minutes,
&& obj->data.top.num < 10) {
// if we limit the buffer and add a bunch of space after, it stops the thing from
// moving other shit around, which is really fucking annoying
- snprintf(p, 17,
- "%s ",
- cur->cpu[obj->data.top.
- num]->name);
+ snprintf(p, 17, "%s ", cur->cpu[obj->data.top.num]->name);
} else if (obj->data.top.type == TOP_CPU
&& obj->data.top.num >= 0
&& obj->data.top.num < 10) {
int added = 0;
tailstring *head = NULL;
tailstring *headtmp = NULL;
+ tailstring *freetmp = NULL;
fp = fopen(obj->data.tail.logfile, "rt");
if (fp == NULL) {
ERR("tail logfile failed to open");
else {
obj->data.tail.readlines = 0;
- while (fgets(obj->data.tail.buffer, TEXT_BUFFER_SIZE*4, fp) != NULL) {
+ while (fgets(obj->data.tail.buffer, TEXT_BUFFER_SIZE*20, fp) != NULL) {
if (added >= 30) {
freelasttail(head);
}
}
fclose(fp);
+ freetmp = head;
if (obj->data.tail.readlines > 0) {
for (i = 0;i < obj->data.tail.wantedlines + 1 && i < obj->data.tail.readlines; i++) {
addtail(&headtmp, head->data);
head = head->next;
}
+ freetail(freetmp);
+ freetmp = headtmp;
strcpy(obj->data.tail.buffer, headtmp->data);
headtmp = headtmp->next;
for (i = 1;i < obj->data.tail.wantedlines + 1 && i < obj->data.tail.readlines; i++) {
if (headtmp) {
- strncat(obj->data.tail.buffer, headtmp->data, (TEXT_BUFFER_SIZE * 6 / obj->data.tail.wantedlines) - strlen(obj->data.tail.buffer)); /* without strlen() at the end this becomes a possible */
+ strncat(obj->data.tail.buffer, headtmp->data, (TEXT_BUFFER_SIZE * 20) - strlen(obj->data.tail.buffer)); /* without strlen() at the end this becomes a possible */
headtmp = headtmp->next;
}
}
}
snprintf(p, n, "%s", obj->data.tail.buffer);
- freetail(headtmp);
+ freetail(freetmp);
+ }
+ else {
+ strcpy(obj->data.tail.buffer, "Logfile Empty");
+ snprintf(p, n, "Logfile Empty");
+ }
+ }
+ }
+ }
+ OBJ(head) {
+ if (current_update_time -obj->data.tail.last_update < obj->data.tail.interval) {
+ snprintf(p, n, "%s", obj->data.tail.buffer);
+ } else {
+ obj->data.tail.last_update = current_update_time;
+ FILE *fp;
+ tailstring *head = NULL;
+ tailstring *headtmp = NULL;
+ tailstring *freetmp = NULL;
+ fp = fopen(obj->data.tail.logfile, "rt");
+ if (fp == NULL) {
+ ERR("head logfile failed to open");
+ }
+ else {
+ obj->data.tail.readlines = 0;
+ while (fgets(obj->data.tail.buffer, TEXT_BUFFER_SIZE*20, fp) != NULL && obj->data.tail.readlines <= obj->data.tail.wantedlines) {
+ addtail(&head, obj->data.tail.buffer);
+ obj->data.tail.readlines++;
+ }
+ fclose(fp);
+ freetmp = head;
+ if (obj->data.tail.readlines > 0) {
+ while (head) {
+ addtail(&headtmp, head->data);
+ head = head->next;
+ }
+ freetail(freetmp);
+ freetmp = headtmp;
+ strcpy(obj->data.tail.buffer, headtmp->data);
+ headtmp = headtmp->next;
+ while (headtmp) {
+ strncat(obj->data.tail.buffer, headtmp->data, (TEXT_BUFFER_SIZE * 20) - strlen(obj->data.tail.buffer)); /* without strlen() at the end this becomes a possible */
+ headtmp = headtmp->next;
+ }
+ freetail(freetmp);
+ /* get rid of any ugly newlines at the end */
+ if (obj->data.tail.buffer[strlen(obj->data.tail.buffer)-1] == '\n') {
+ obj->data.tail.buffer[strlen(obj->data.tail.buffer)-1] = '\0';
+ }
+ snprintf(p, n, "%s", obj->data.tail.buffer);
}
else {
strcpy(obj->data.tail.buffer, "Logfile Empty");
snprintf(p, n, "Logfile Empty");
}
- freetail(head);
}
}
}
-
-
break;
}
{
#ifdef XFT
if (use_xft) {
- if (window.xftdraw != NULL)
+ if (window.xftdraw != NULL) {
XftDrawDestroy(window.xftdraw);
+ }
window.xftdraw = XftDrawCreate(display, window.drawable,
DefaultVisual(display,
screen),
#endif /* X11 */
}
+static inline int get_string_width_special(char *s)
+{
+ if (!s) {
+ return 0;
+ }
+#ifdef X11
+ char *p, *final;
+ p = strdup(s);
+ final = p;
+ int index = 1;
+ int width = 0;
+ unsigned int i;
+ while (*p) {
+ if (*p == SPECIAL_CHAR) {
+ /* shift everything over by 1 so that the special char doesn't mess up the size calculation */
+ for (i = 0; i < strlen(p); i++) {
+ *(p + i) = *(p + i + 1);
+ }
+ if (specials[special_index+index].type == GRAPH || specials[special_index+index].type == BAR) {
+ width += specials[special_index+index].width;
+ }
+ index++;
+ } else {
+ p++;
+ }
+ }
+ if (strlen(final) > 1) {
+ width += calc_text_width(final, strlen(final));
+ }
+ free(final);
+ return width;
+#else
+ return strlen(s);
+#endif /* X11 */
+}
+
int fontchange = 0;
#ifdef X11
w += get_string_width(s);
if (w > text_width)
text_width = w;
+ if (text_width > maximum_width && maximum_width)
+ text_width = maximum_width;
text_height += h;
if (fontchange) {
text_width += 1;
if (text_height < minimum_height)
text_height = minimum_height;
+ if (text_width > maximum_width && maximum_width > 0)
+ text_width = maximum_width;
}
/* get text position on workarea */
}
}
}
+#ifdef X11
+ if (text_width == maximum_width) {
+ /* this means the text is probably pushing the limit, so we'll chop it */
+ while (cur_x + get_string_width(tmpstring2) - text_start_x > maximum_width && strlen(tmpstring2) > 0) {
+ tmpstring2[strlen(tmpstring2)-1] = '\0';
+ }
+ }
+#endif /* X11 */
s = tmpstring2;
#ifdef X11
#ifdef XFT
}
long redmask, greenmask, bluemask;
-short colour_depth = 0;
void set_up_gradient()
{
case BAR:
{
+ if (cur_x - text_start_x > maximum_width && maximum_width > 0) {
+ break;
+ }
int h =
specials[special_index].height;
int bar_usage =
specials[special_index].arg;
- int by =
- cur_y - (font_ascent() +
- h) / 2 - 1;
+ int by;
+
+#ifdef XFT
+ if (use_xft) {
+ by = cur_y - (font_ascent() + h) / 2 - 1;
+ } else
+#endif
+ {
+ by = cur_y - (font_ascent()/2) - 1;
+ }
+ if (h < (font_height())) {
+ by -= h / 2 - 1;
+ }
w = specials[special_index].width;
if (w == 0)
w = text_start_x +
break;
case GRAPH:
- {
+ {
+ if (cur_x - text_start_x > maximum_width && maximum_width > 0) {
+ break;
+ }
int h =
specials[special_index].height;
int by;
#ifdef XFT
if (use_xft) {
- by = cur_y - (font_ascent() +
- h) / 2 - 1;
+ by = cur_y - (font_ascent() + h) / 2 - 1;
} else
#endif
{
- by = cur_y - (font_ascent()/2);
+ by = cur_y - (font_ascent()/2) - 1;
+ }
+ if (h < (font_height())) {
+ by -= h / 2 - 1;
}
w = specials[special_index].width;
if (w == 0)
j++;
}
XDrawLine(display, window.drawable, window.gc, cur_x + i + 2, by + h, cur_x + i + 2, by + h - specials[special_index].graph[j] * (h - 1) / specials[special_index].graph_scale); /* this is mugfugly, but it works */
- }
+ }
if (specials[special_index].
height > cur_y_add
&& specials[special_index].
selected_font = specials[special_index].font_added;
cur_y += font_ascent();
#ifdef XFT
- if (!use_xft)
+ if (!use_xft || use_xdbe)
#endif
{
set_font();
case ALIGNR:
{
- int pos_x = text_width + gap_x - get_string_width(p) /*- border_margin*2 - 1*/;
- /*printf("pos_x %i text_start_x %i text_width %i cur_x %i get_string_width(p) %i gap_x %i specials[special_index].arg %i border_margin %i border_width %i\n", pos_x, text_start_x, text_width, cur_x, get_string_width(p), gap_x, specials[special_index].arg, border_margin, border_width);*/
+ int pos_x = text_start_x + text_width - get_string_width_special(s) /*+ border_margin*/;
+ /*printf("pos_x %i text_start_x %i text_width %i cur_x %i get_string_width(p) %i gap_x %i specials[special_index].arg %i border_margin %i border_width %i\n", pos_x, text_start_x, text_width, cur_x, get_string_width_special(s), gap_x, specials[special_index].arg, border_margin, border_width);*/
if (pos_x > specials[special_index].arg && pos_x > cur_x) {
- cur_x = pos_x - specials[special_index].arg;
+ cur_x = pos_x - specials[special_index].arg;
}
}
break;
case ALIGNC:
{
- int pos_x = (text_width)/2 - get_string_width(p)/2 - (cur_x - text_start_x);
- /*printf("pos_x %i text_start_x %i text_width %i cur_x %i get_string_width(p) %i gap_x %i specials[special_index].arg %i\n", pos_x, text_start_x, text_width, cur_x, get_string_width(p), gap_x, specials[special_index].arg);*/
+ int pos_x = (text_width)/2 - get_string_width_special(s)/2 - (cur_x - text_start_x);
+ /*int pos_x = text_start_x + text_width/2 - get_string_width_special(s)/2;*/
+ /*printf("pos_x %i text_start_x %i text_width %i cur_x %i get_string_width(p) %i gap_x %i specials[special_index].arg %i\n", pos_x, text_start_x, text_width, cur_x, get_string_width(s), gap_x, specials[special_index].arg);*/
if (pos_x >
specials[special_index].arg)
w = pos_x -
static void clear_text(int exposures)
{
#ifdef XDBE
- if (use_xdbe)
+ if (use_xdbe) {
return; /* The swap action is XdbeBackground, which clears */
+ } else
#endif
+ {
/* there is some extra space for borders and outlines */
XClearArea(display, window.drawable,
text_start_x - border_margin - 1,
text_width + border_margin * 2 + 2,
text_height + border_margin * 2 + 2,
exposures ? True : 0);
+ }
}
#endif /* X11 */
update_text();
#ifdef X11
}
+#ifdef OWN_WINDOW
+ if (own_window) {
+ set_transparent_background(window.window);
+ }
+#endif
}
-
+
if (need_to_update) {
#ifdef OWN_WINDOW
int wx = window.x, wy = window.y;
need_to_update = 0;
update_text_area();
-
#ifdef OWN_WINDOW
if (own_window) {
/* resize window if it isn't right size */
window.window,
window.width,
window.height);
- }
+ }
/* move window if it isn't in right position */
if (!fixed_pos
while (XPending(display)) {
XEvent ev;
XNextEvent(display, &ev);
-
switch (ev.type) {
case Expose:
{
#ifdef OWN_WINDOW
case ReparentNotify:
/* set background to ParentRelative for all parents */
- if (own_window)
+ if (own_window) {
set_transparent_background(window.
- window);
+ window);
+ }
break;
case ConfigureNotify:
text_height =
window.height -
border_margin * 2 - 1;
+ if (text_width > maximum_width && maximum_width > 0)
+ text_width = maximum_width;
}
/* if position isn't what expected, set fixed pos, total_updates
* avoids setting fixed_pos when window is set to weird locations
* when started */
- if (total_updates >= 2
+ /*if (total_updates >= 2 this is broken
&& !fixed_pos
&& (window.x != ev.xconfigure.x
|| window.y !=
&& (ev.xconfigure.x != 0
|| ev.xconfigure.y != 0)) {
fixed_pos = 1;
- }
+ }*/
+ set_font();
}
break;
#endif
r.width = text_width + border_margin * 2;
r.height = text_height + border_margin * 2;
XUnionRectWithRegion(&r, region, region);
- }
+ }
#endif
XSetRegion(display, window.gc, region);
#ifdef XFT
- if (use_xft)
+ if (use_xft) {
XftDrawSetClip(window.xftdraw, region);
+ }
#endif
#endif /* X11 */
draw_stuff();
{
#ifdef X11
#ifdef XDBE
- if (use_xdbe)
+ if (use_xdbe) {
XdbeDeallocateBackBufferName(display, window.back_buffer);
+ }
#endif
#ifdef OWN_WINDOW
if (own_window)
gap_y = 5;
minimum_width = 5;
minimum_height = 5;
+ maximum_width = 0;
#ifdef OWN_WINDOW
own_window = 0;
#endif
#define CONF2(a) if (strcasecmp(name, a) == 0)
#define CONF(a) else CONF2(a)
#define CONF3(a,b) \
-else if (strcasecmp(name, a) == 0 || strcasecmp(name, a) == 0)
+else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
#ifdef X11
#ifdef XDBE
CONF("double_buffer") {
- if (!own_window) {
use_xdbe = string_to_bool(value);
- }
}
#endif
#ifdef X11
}
#ifdef X11
CONF("minimum_size") {
+ if (value) {
+ if (sscanf
+ (value, "%d %d", &minimum_width,
+ &minimum_height) != 2)
+ if (sscanf
+ (value, "%d",
+ &minimum_width) != 1)
+ CONF_ERR;
+ } else
+ CONF_ERR;
+ }
+ CONF("maximum_width") {
if (value) {
- if (sscanf
- (value, "%d %d", &minimum_width,
- &minimum_height) != 2)
- if (sscanf
- (value, "%d",
- &minimum_width) != 1)
- CONF_ERR;
+ if (sscanf(value, "%d", &maximum_width) != 1)
+ CONF_ERR;
} else
CONF_ERR;
}
#ifdef OWN_WINDOW
CONF("own_window") {
own_window = string_to_bool(value);
-#ifdef XDBE
- use_xdbe = 0;
-#endif
+ }
+ CONF("own_window_transparent") {
+ set_transparent = string_to_bool(value);
+ }
+ CONF("own_window_colour") {
+ background_colour = get_x11_color(value);
}
#endif
CONF("stippled_borders") {
}
#endif
- if (current_config != NULL)
+ if (current_config != NULL && fopen((const char *)current_config, (const char *)"r"))
load_config_file(current_config);
- else
+ else {
set_default_configurations();
+ }
#ifdef MAIL_FILE
if (current_mail_spool == NULL) {
/* handle other command line arguments */
+#if defined(__FreeBSD__) || defined (__OpenBSD__) || defined(__NetBSD__)
+ optind = optreset = 1;
+#else
optind = 0;
-
+#endif
+
while (1) {
int c = getopt(argc,
argv,
#ifdef OWN_WINDOW
case 'o':
own_window = 1;
-#ifdef XDBE
- use_xdbe = 0;
-#endif
break;
#endif
#ifdef XDBE
case 'b':
- use_xdbe = 1;
+ use_xdbe = 1;
break;
#endif
#endif /* X11 */
(own_window,
text_width + border_margin * 2 + 1,
text_height + border_margin * 2 + 1,
- on_bottom, fixed_pos);
+ on_bottom, fixed_pos, set_transparent, background_colour);
#else
init_window
(own_window,
text_width + border_margin * 2 + 1,
text_height + border_margin * 2 + 1,
- on_bottom);
+ on_bottom, set_transparent, background_colour);
#endif
#ifdef X11
#ifdef OWN_WINDOW
- if (own_window && !fixed_pos)
+ if (own_window && !fixed_pos) {
XMoveWindow(display, window.window, window.x, window.y);
+ }
+ if (own_window) {
+ set_transparent_background(window.window);
+ }
#endif
create_gc();