percent_print(p, p_max_size,
round_to_int(cur->cpu_usage[obj->data.i] * 100.0));
}
-#ifdef X11
OBJ(cpugauge)
- new_gauge(obj, p, round_to_int(cur->cpu_usage[obj->data.i] * 255.0));
-#endif /* X11 */
+ new_gauge(obj, p, p_max_size, round_to_int(cur->cpu_usage[obj->data.i] * 255.0));
OBJ(cpubar) {
new_bar(obj, p, p_max_size, round_to_int(cur->cpu_usage[obj->data.i] * 255.0));
}
OBJ(execp) {
print_execp(obj, p, p_max_size);
}
-#ifdef X11
OBJ(execgauge) {
print_execgauge(obj, p, p_max_size);
}
-#endif /* X11 */
OBJ(execbar) {
print_execbar(obj, p, p_max_size);
}
OBJ(execigraph) {
print_execigraph(obj, p, p_max_size);
}
+#endif /* X11 */
OBJ(execigauge) {
print_execigauge(obj, p, p_max_size);
}
-#endif /* X11 */
OBJ(execi) {
print_execi(obj, p, p_max_size);
}
OBJ(lua_graph) {
print_lua_graph(obj, p, p_max_size);
}
+#endif /* X11 */
OBJ(lua_gauge) {
print_lua_gauge(obj, p, p_max_size);
}
-#endif /* X11 */
#endif /* HAVE_LUA */
#ifdef HDDTEMP
OBJ(hddtemp) {
if (cur->memmax)
percent_print(p, p_max_size, cur->mem * 100 / cur->memmax);
}
-#ifdef X11
OBJ(memgauge){
- new_gauge(obj, p, cur->memmax ? (cur->mem * 255) / (cur->memmax) : 0);
+ new_gauge(obj, p, p_max_size, cur->memmax ? (cur->mem * 255) / (cur->memmax) : 0);
}
-#endif /* X11 */
OBJ(membar) {
new_bar(obj, p, p_max_size, cur->memmax ? (cur->mem * 255) / (cur->memmax) : 0);
}
progress = atof(cur->apcupsd.items[APCUPSD_LOAD]);
new_graph(obj, p, (int)progress);
}
+#endif /* X11 */
OBJ(apcupsd_loadgauge) {
double progress;
progress = atof(cur->apcupsd.items[APCUPSD_LOAD]) / 100.0 * 255.0;
- new_gauge(obj, p, (int)progress);
+ new_gauge(obj, p, p_max_size, (int)progress);
}
-#endif /* X11 */
OBJ(apcupsd_charge) {
snprintf(p, p_max_size, "%s",
cur->apcupsd.items[APCUPSD_CHARGE]);
END OBJ(cpu, &update_cpu_usage)
SCAN_CPU(arg, obj->data.i);
DBGP2("Adding $cpu for CPU %d", obj->data.i);
-#ifdef X11
END OBJ(cpugauge, &update_cpu_usage)
SCAN_CPU(arg, obj->data.i);
scan_gauge(obj, arg);
DBGP2("Adding $cpugauge for CPU %d", obj->data.i);
-#endif /* X11 */
END OBJ(cpubar, &update_cpu_usage)
SCAN_CPU(arg, obj->data.i);
scan_bar(obj, arg);
scan_exec_arg(obj, arg);
END OBJ(execbar, 0)
scan_exec_arg(obj, arg);
-#ifdef X11
END OBJ(execgauge, 0)
scan_exec_arg(obj, arg);
+#ifdef X11
END OBJ(execgraph, 0)
scan_execgraph_arg(obj, arg);
#endif /* X11 */
#ifdef X11
END OBJ_ARG(execigraph, 0, "execigraph needs arguments")
scan_execgraph_arg(obj, arg);
+#endif /* X11 */
END OBJ_ARG(execigauge, 0, "execigauge needs arguments")
scan_execi_arg(obj, arg);
-#endif /* X11 */
END OBJ_ARG(execi, 0, "execi needs arguments")
scan_execi_arg(obj, arg);
END OBJ_ARG(execpi, 0, "execpi needs arguments")
END OBJ(memfree, &update_meminfo)
END OBJ(memmax, &update_meminfo)
END OBJ(memperc, &update_meminfo)
-#ifdef X11
END OBJ(memgauge, &update_meminfo)
scan_gauge(obj, arg);
-#endif /* X11*/
END OBJ(membar, &update_meminfo)
scan_bar(obj, arg);
#ifdef X11
} else {
CRIT_ERR(obj, free_at_crash, "lua_graph needs arguments: <function name> [height],[width] [gradient colour 1] [gradient colour 2] [scale] [-t] [-l]");
}
+#endif /* X11 */
END OBJ_ARG(lua_gauge, 0, "lua_gauge needs arguments: <height>,<width> <function name> [function parameters]")
arg = scan_gauge(obj, arg);
if (arg) {
} else {
CRIT_ERR(obj, free_at_crash, "lua_gauge needs arguments: <height>,<width> <function name> [function parameters]");
}
-#endif /* X11 */
#endif /* HAVE_LUA */
#ifdef HDDTEMP
END OBJ(hddtemp, &update_hddtemp)
char* buf = 0;
buf = scan_graph(obj, arg, 0);
if (buf) free(buf);
+#endif /* X11 */
END OBJ(apcupsd_loadgauge, &update_apcupsd)
scan_gauge(obj, arg);
-#endif /* X11 */
END OBJ(apcupsd_charge, &update_apcupsd)
END OBJ(apcupsd_timeleft, &update_apcupsd)
END OBJ(apcupsd_temp, &update_apcupsd)
break;
case OBJ_exec:
case OBJ_execbar:
-#ifdef X11
case OBJ_execgauge:
+#ifdef X11
case OBJ_execgraph:
#endif
case OBJ_execp:
case OBJ_lua_bar:
#ifdef X11
case OBJ_lua_graph:
- case OBJ_lua_gauge:
#endif /* X11 */
+ case OBJ_lua_gauge:
free(data.s);
break;
#endif /* HAVE_LUA */
case OBJ_texeci:
#ifdef X11
case OBJ_execigraph:
- case OBJ_execigauge:
#endif /* X11 */
+ case OBJ_execigauge:
free_execi(obj);
break;
case OBJ_nameserver:
case OBJ_apcupsd_loadbar:
#ifdef X11
case OBJ_apcupsd_loadgraph:
- case OBJ_apcupsd_loadgauge:
#endif /* X11 */
+ case OBJ_apcupsd_loadgauge:
case OBJ_apcupsd_charge:
case OBJ_apcupsd_timeleft:
case OBJ_apcupsd_temp:
if (barnum >= 0.0) {
barnum /= 100;
- new_gauge(obj, p, round_to_int(barnum * 255.0));
+ new_gauge(obj, p, p_max_size, round_to_int(barnum * 255.0));
}
}
}
ed->last_update = current_update_time;
}
- new_gauge(obj, p, round_to_int(ed->barnum));
+ new_gauge(obj, p, p_max_size, round_to_int(ed->barnum));
}
#endif /* X11 */
return;
if (llua_getnumber(obj->data.s, &per)) {
- new_gauge(obj, p, (per/100.0 * 255));
+ new_gauge(obj, p, p_max_size, (per/100.0 * 255));
}
}
#endif /* X11 */
return &specials[special_count++];
}
+void new_gauge_in_shell(struct text_object *obj, char *p, int p_max_size, int usage)
+{
+ static const char *gaugevals[] = { "_. ", "\\. ", " | ", " ./", " ._" };
+ (void)obj;
+
+ snprintf(p, p_max_size, "%s", gaugevals[round_to_int((double)usage * 4 / 255)]);
+}
+
#ifdef X11
-void new_gauge(struct text_object *obj, char *buf, int usage)
+void new_gauge_in_x11(struct text_object *obj, char *buf, int usage)
{
struct special_t *s = 0;
struct gauge *g = obj->special_data;
s = new_special(buf, GAUGE);
- s->arg = (usage > 255) ? 255 : ((usage < 0) ? 0 : usage);
+ s->arg = usage;
s->width = g->width;
s->height = g->height;
}
+#endif /* X11 */
+
+void new_gauge(struct text_object *obj, char *p, int p_max_size, int usage)
+{
+ if (!p_max_size)
+ return;
+ usage = (usage > 255) ? 255 : ((usage < 0) ? 0 : usage);
+
+#ifdef X11
+ if (output_methods & TO_X)
+ new_gauge_in_x11(obj, p, usage);
+ else
+#endif /* X11 */
+ new_gauge_in_shell(obj, p, p_max_size, usage);
+}
+
+#ifdef X11
void new_font(char *buf, char *args)
{
if ((output_methods & TO_X) == 0)
void scan_stippled_hr(struct text_object *, const char*);
/* printing specials */
-void new_gauge(struct text_object *, char *, int);
+void new_gauge(struct text_object *, char *, int, int);
void new_bar(struct text_object *, char *, int, int);
void new_font(char *, char *);
void new_graph(struct text_object *, char *, double);