1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-25 20:11:11 +00:00

Let membar work in shell

This commit is contained in:
Nikolas Garofil 2009-06-01 12:19:25 +02:00
parent 0cb91fc3db
commit bfc791f08b
5 changed files with 38 additions and 23 deletions

View File

@ -38,7 +38,7 @@ ${scroll 16 $nodename - $sysname $kernel on $machine | }
Uptime: $uptime Uptime: $uptime
Frequency (in MHz): $freq Frequency (in MHz): $freq
Frequency (in GHz): $freq_g Frequency (in GHz): $freq_g
RAM Usage: $mem/$memmax - $memperc% RAM Usage: $mem/$memmax - $memperc% ${membar 4}
Swap Usage: $swap/$swapmax - $swapperc% Swap Usage: $swap/$swapmax - $swapperc%
CPU Usage: $cpu% CPU Usage: $cpu%
Processes: $processes Running: $running_processes Processes: $processes Running: $running_processes

View File

@ -2241,9 +2241,11 @@ static struct text_object *construct_text_object(const char *s,
END OBJ(memgauge, INFO_MEM) END OBJ(memgauge, INFO_MEM)
SIZE_DEFAULTS(gauge); SIZE_DEFAULTS(gauge);
scan_gauge(arg, &obj->data.pair.a, &obj->data.pair.b); scan_gauge(arg, &obj->data.pair.a, &obj->data.pair.b);
#endif /* X11*/
END OBJ(membar, INFO_MEM) END OBJ(membar, INFO_MEM)
SIZE_DEFAULTS(bar); SIZE_DEFAULTS(bar);
scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b); scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
#ifdef X11
END OBJ(memgraph, INFO_MEM) END OBJ(memgraph, INFO_MEM)
char *buf = 0; char *buf = 0;
SIZE_DEFAULTS(graph); SIZE_DEFAULTS(graph);
@ -2253,7 +2255,7 @@ static struct text_object *construct_text_object(const char *s,
if (buf) { if (buf) {
free(buf); free(buf);
} }
#endif #endif /* X11*/
END OBJ(mixer, INFO_MIXER) END OBJ(mixer, INFO_MIXER)
obj->data.l = mixer_init(arg); obj->data.l = mixer_init(arg);
END OBJ(mixerl, INFO_MIXER) END OBJ(mixerl, INFO_MIXER)
@ -3937,7 +3939,7 @@ static void generate_text_internal(char *p, int p_max_size,
new_gauge(p, obj->a, obj->b, round_to_int(barnum * 255.0)); new_gauge(p, obj->a, obj->b, round_to_int(barnum * 255.0));
} }
} }
#endif #endif /* X11 */
OBJ(execbar) { OBJ(execbar) {
double barnum; double barnum;
@ -3950,12 +3952,12 @@ static void generate_text_internal(char *p, int p_max_size,
barnum /= 100; barnum /= 100;
new_bar(p, obj->a, obj->b, round_to_int(barnum * 255.0)); new_bar(p, obj->a, obj->b, round_to_int(barnum * 255.0));
}else{ }else{
#endif #endif /* X11 */
if(!obj->a) obj->a = DEFAULT_BAR_WIDTH_NO_X; if(!obj->a) obj->a = DEFAULT_BAR_WIDTH_NO_X;
new_bar_in_shell(p, p_max_size, barnum, obj->a); new_bar_in_shell(p, p_max_size, barnum, obj->a);
#ifdef X11 #ifdef X11
} }
#endif #endif /* X11 */
} }
} }
#ifdef X11 #ifdef X11
@ -4043,7 +4045,7 @@ static void generate_text_internal(char *p, int p_max_size,
} }
new_gauge(p, obj->a, obj->b, round_to_int(obj->f)); new_gauge(p, obj->a, obj->b, round_to_int(obj->f));
} }
#endif #endif /* X11 */
OBJ(execi) { OBJ(execi) {
if (current_update_time - obj->data.execi.last_update if (current_update_time - obj->data.execi.last_update
>= obj->data.execi.interval >= obj->data.execi.interval
@ -4573,16 +4575,27 @@ static void generate_text_internal(char *p, int p_max_size,
new_gauge(p, obj->data.pair.a, obj->data.pair.b, new_gauge(p, obj->data.pair.a, obj->data.pair.b,
cur->memmax ? (cur->mem * 255) / (cur->memmax) : 0); cur->memmax ? (cur->mem * 255) / (cur->memmax) : 0);
} }
#endif /* X11 */
OBJ(membar) { OBJ(membar) {
new_bar(p, obj->data.pair.a, obj->data.pair.b, #ifdef X11
cur->memmax ? (cur->mem * 255) / (cur->memmax) : 0); if(output_methods & TO_X) {
new_bar(p, obj->data.pair.a, obj->data.pair.b,
cur->memmax ? (cur->mem * 255) / (cur->memmax) : 0);
}else{
#endif /* X11 */
if(!obj->data.pair.a) obj->data.pair.a = DEFAULT_BAR_WIDTH_NO_X;
new_bar_in_shell(p, p_max_size, cur->memmax ? (cur->mem * 100) / (cur->memmax) : 0, obj->data.pair.a);
#ifdef X11
}
#endif /* X11 */
} }
#ifdef X11
OBJ(memgraph) { OBJ(memgraph) {
new_graph(p, obj->a, obj->b, obj->c, obj->d, new_graph(p, obj->a, obj->b, obj->c, obj->d,
cur->memmax ? (cur->mem * 100.0) / (cur->memmax) : 0.0, cur->memmax ? (cur->mem * 100.0) / (cur->memmax) : 0.0,
100, 1, obj->char_a, obj->char_b); 100, 1, obj->char_a, obj->char_b);
} }
#endif #endif /* X11 */
/* mixer stuff */ /* mixer stuff */
OBJ(mixer) { OBJ(mixer) {
percent_print(p, p_max_size, mixer_get_avg(obj->data.l)); percent_print(p, p_max_size, mixer_get_avg(obj->data.l));

View File

@ -28,7 +28,7 @@
#include "colours.h" #include "colours.h"
#ifdef X11 #ifdef X11
#include "fonts.h" #include "fonts.h"
#endif #endif /* X11 */
#include "logging.h" #include "logging.h"
#include "specials.h" #include "specials.h"
#include <math.h> #include <math.h>
@ -46,7 +46,7 @@ int default_bar_width = 0, default_bar_height = 6;
#ifdef X11 #ifdef X11
int default_graph_width = 0, default_graph_height = 25; int default_graph_width = 0, default_graph_height = 25;
int default_gauge_width = 40, default_gauge_height = 25; int default_gauge_width = 40, default_gauge_height = 25;
#endif #endif /* X11 */
/* /*
* Scanning arguments to various special text objects * Scanning arguments to various special text objects
@ -73,6 +73,7 @@ const char *scan_gauge(const char *args, int *w, int *h)
return args; return args;
} }
#endif /* X11 */
const char *scan_bar(const char *args, int *w, int *h) const char *scan_bar(const char *args, int *w, int *h)
{ {
@ -92,6 +93,7 @@ const char *scan_bar(const char *args, int *w, int *h)
return args; return args;
} }
#ifdef X11
char *scan_font(const char *args) char *scan_font(const char *args)
{ {
if (args && *args) { if (args && *args) {
@ -195,7 +197,7 @@ char *scan_graph(const char *args, int *w, int *h,
return strndup(buf, text_buffer_size); return strndup(buf, text_buffer_size);
} }
} }
#endif #endif /* X11 */
/* /*
* Printing various special text objects * Printing various special text objects
@ -378,7 +380,7 @@ void new_bg(char *buf, long c)
new_special(buf, BG)->arg = c; new_special(buf, BG)->arg = c;
} }
#endif #endif /* X11 */
void new_bar_in_shell(char* buffer, int buf_max_size, double usage, int width) void new_bar_in_shell(char* buffer, int buf_max_size, double usage, int width)
{ {

View File

@ -88,10 +88,10 @@ extern int default_gauge_height;
/* max number of specials allowed (TODO: use linked list instead) */ /* max number of specials allowed (TODO: use linked list instead) */
extern int max_specials; extern int max_specials;
#ifdef X11
/* scanning special arguments */ /* scanning special arguments */
const char *scan_gauge(const char *, int *, int *);
const char *scan_bar(const char *, int *, int *); const char *scan_bar(const char *, int *, int *);
#ifdef X11
const char *scan_gauge(const char *, int *, int *);
char *scan_font(const char *); char *scan_font(const char *);
char *scan_graph(const char *, int *, int *, unsigned int *, char *scan_graph(const char *, int *, int *, unsigned int *,
unsigned int *, unsigned int *, char *, char *); unsigned int *, unsigned int *, char *, char *);

View File

@ -156,7 +156,7 @@ enum text_object_type {
OBJ_smapi, OBJ_smapi,
#ifdef X11 #ifdef X11
OBJ_smapi_bat_bar, OBJ_smapi_bat_bar,
#endif #endif /* X11 */
OBJ_smapi_bat_perc, OBJ_smapi_bat_perc,
OBJ_smapi_bat_temp, OBJ_smapi_bat_temp,
OBJ_smapi_bat_power, OBJ_smapi_bat_power,
@ -182,7 +182,7 @@ enum text_object_type {
OBJ_wireless_link_qual_perc, OBJ_wireless_link_qual_perc,
#ifdef X11 #ifdef X11
OBJ_wireless_link_bar, OBJ_wireless_link_bar,
#endif #endif /* X11 */
#endif /* __linux__ */ #endif /* __linux__ */
#if defined(__FreeBSD__) || defined(__linux__) #if defined(__FreeBSD__) || defined(__linux__)
OBJ_if_up, OBJ_if_up,
@ -221,9 +221,9 @@ enum text_object_type {
OBJ_memfree, OBJ_memfree,
#ifdef X11 #ifdef X11
OBJ_memgauge, OBJ_memgauge,
OBJ_membar,
OBJ_memgraph, OBJ_memgraph,
#endif #endif /* X11 */
OBJ_membar,
OBJ_memmax, OBJ_memmax,
OBJ_memperc, OBJ_memperc,
OBJ_mixer, OBJ_mixer,
@ -233,12 +233,12 @@ enum text_object_type {
OBJ_mixerbar, OBJ_mixerbar,
OBJ_mixerlbar, OBJ_mixerlbar,
OBJ_mixerrbar, OBJ_mixerrbar,
#endif #endif /* X11 */
OBJ_if_mixer_mute, OBJ_if_mixer_mute,
#ifdef X11 #ifdef X11
OBJ_monitor, OBJ_monitor,
OBJ_monitor_number, OBJ_monitor_number,
#endif #endif /* X11 */
OBJ_nameserver, OBJ_nameserver,
OBJ_nodename, OBJ_nodename,
OBJ_nvidia, OBJ_nvidia,
@ -251,7 +251,7 @@ enum text_object_type {
OBJ_swap, OBJ_swap,
#ifdef X11 #ifdef X11
OBJ_swapbar, OBJ_swapbar,
#endif #endif /* X11 */
OBJ_swapmax, OBJ_swapmax,
OBJ_swapperc, OBJ_swapperc,
OBJ_sysname, OBJ_sysname,
@ -266,7 +266,7 @@ enum text_object_type {
OBJ_upspeedf, OBJ_upspeedf,
#ifdef X11 #ifdef X11
OBJ_upspeedgraph, OBJ_upspeedgraph,
#endif #endif /* X11 */
OBJ_uptime, OBJ_uptime,
OBJ_uptime_short, OBJ_uptime_short,
OBJ_user_names, OBJ_user_names,