Let fs_bar and fs_bar_free work in shell

This commit is contained in:
Nikolas Garofil
2009-06-01 16:09:34 +02:00
parent faa9086168
commit 1a9d0bdccd
3 changed files with 59 additions and 29 deletions

View File

@@ -43,7 +43,7 @@ Swap Usage: $swap/$swapmax - $swapperc% ${swapbar 4}
CPU Usage: $cpu% ${cpubar 4} CPU Usage: $cpu% ${cpubar 4}
Processes: $processes Running: $running_processes Processes: $processes Running: $running_processes
File systems: File systems:
/ ${fs_used /}/${fs_size /} / ${fs_used /}/${fs_size /} ${fs_bar 6 /}
Networking: Networking:
Up: ${upspeed eth0} - Down: ${downspeed eth0} Up: ${upspeed eth0} - Down: ${downspeed eth0}
Name PID CPU% MEM% Name PID CPU% MEM%

View File

@@ -1498,7 +1498,7 @@ static struct text_object *construct_text_object(const char *s,
obj->data.loadavg[0] = (r >= 1) ? (unsigned char) a : 0; obj->data.loadavg[0] = (r >= 1) ? (unsigned char) a : 0;
free(buf); free(buf);
} }
#endif #endif /* X11 */
END OBJ(diskio, INFO_DISKIO) END OBJ(diskio, INFO_DISKIO)
obj->data.diskio = prepare_diskio_stat(dev_name(arg)); obj->data.diskio = prepare_diskio_stat(dev_name(arg));
END OBJ(diskio_read, INFO_DISKIO) END OBJ(diskio_read, INFO_DISKIO)
@@ -1533,7 +1533,7 @@ static struct text_object *construct_text_object(const char *s,
obj->data.diskio = prepare_diskio_stat(dev_name(buf)); obj->data.diskio = prepare_diskio_stat(dev_name(buf));
if (buf) if (buf)
free(buf); free(buf);
#endif #endif /* X11 */
END OBJ(color, 0) END OBJ(color, 0)
#ifdef X11 #ifdef X11
if (output_methods & TO_X) { if (output_methods & TO_X) {
@@ -1563,7 +1563,7 @@ static struct text_object *construct_text_object(const char *s,
#ifdef X11 #ifdef X11
END OBJ(font, 0) END OBJ(font, 0)
obj->data.s = scan_font(arg); obj->data.s = scan_font(arg);
#endif #endif /* X11 */
END OBJ(conky_version, 0) END OBJ(conky_version, 0)
END OBJ(conky_build_date, 0) END OBJ(conky_build_date, 0)
END OBJ(conky_build_arch, 0) END OBJ(conky_build_arch, 0)
@@ -1590,7 +1590,7 @@ static struct text_object *construct_text_object(const char *s,
buf = strndup(buf ? buf : "DEFAULTNETDEV", text_buffer_size); buf = strndup(buf ? buf : "DEFAULTNETDEV", text_buffer_size);
obj->data.net = get_net_stat(buf); obj->data.net = get_net_stat(buf);
free(buf); free(buf);
#endif #endif /* X11 */
END OBJ(else, 0) END OBJ(else, 0)
obj_be_ifblock_else(ifblock_opaque, obj); obj_be_ifblock_else(ifblock_opaque, obj);
END OBJ(endif, 0) END OBJ(endif, 0)
@@ -1656,7 +1656,7 @@ static struct text_object *construct_text_object(const char *s,
} else { } else {
obj->data.execi.cmd = strndup(arg + n, text_buffer_size); obj->data.execi.cmd = strndup(arg + n, text_buffer_size);
} }
#endif #endif /* X11 */
END OBJ(execi, 0) END OBJ(execi, 0)
int n; int n;
@@ -1711,11 +1711,10 @@ static struct text_object *construct_text_object(const char *s,
obj->data.s = strndup("", text_buffer_size); obj->data.s = strndup("", text_buffer_size);
} }
#endif #endif
#ifdef X11
END OBJ(fs_bar, INFO_FS) END OBJ(fs_bar, INFO_FS)
SIZE_DEFAULTS(bar); SIZE_DEFAULTS(bar);
arg = scan_bar(arg, &obj->data.fsbar.w, &obj->data.fsbar.h); arg = scan_bar(arg, &obj->data.fsbar.w, &obj->data.fsbar.h);
if (arg) { if (arg) {
while (isspace(*arg)) { while (isspace(*arg)) {
arg++; arg++;
} }
@@ -1741,7 +1740,6 @@ static struct text_object *construct_text_object(const char *s,
} }
obj->data.fsbar.fs = prepare_fs_stat(arg); obj->data.fsbar.fs = prepare_fs_stat(arg);
#endif
END OBJ(fs_free, INFO_FS) END OBJ(fs_free, INFO_FS)
if (!arg) { if (!arg) {
arg = "/"; arg = "/";
@@ -4152,19 +4150,36 @@ static void generate_text_internal(char *p, int p_max_size,
timed_thread_unlock(mail->p_timed_thread); timed_thread_unlock(mail->p_timed_thread);
} }
} }
#ifdef X11
OBJ(fs_bar) { OBJ(fs_bar) {
if (obj->data.fs != NULL) { if (obj->data.fs != NULL) {
if (obj->data.fs->size == 0) { if (obj->data.fs->size == 0) {
new_bar(p, obj->data.fsbar.w, obj->data.fsbar.h, 255); #ifdef X11
if(output_methods & TO_X) {
new_bar(p, obj->data.fsbar.w, obj->data.fsbar.h, 255);
}else{
#endif /* X11 */
if(!obj->data.fsbar.w) obj->data.fsbar.w = DEFAULT_BAR_WIDTH_NO_X;
new_bar_in_shell(p, p_max_size, 100, obj->data.fsbar.w);
#ifdef X11
}
#endif /* X11 */
} else { } else {
new_bar(p, obj->data.fsbar.w, obj->data.fsbar.h, #ifdef X11
(int) (255 - obj->data.fsbar.fs->avail * 255 / if(output_methods & TO_X) {
obj->data.fs->size)); new_bar(p, obj->data.fsbar.w, obj->data.fsbar.h,
(int) (255 - obj->data.fsbar.fs->avail * 255 /
obj->data.fs->size));
}else{
#endif /* X11 */
if(!obj->data.fsbar.w) obj->data.fsbar.w = DEFAULT_BAR_WIDTH_NO_X;
new_bar_in_shell(p, p_max_size,
(int) (100 - obj->data.fsbar.fs->avail * 100 / obj->data.fs->size), obj->data.fsbar.w);
#ifdef X11
}
#endif /* X11 */
} }
} }
} }
#endif
OBJ(fs_free) { OBJ(fs_free) {
if (obj->data.fs != NULL) { if (obj->data.fs != NULL) {
human_readable( (obj->data.fs->free ? obj->data.fs->free : human_readable( (obj->data.fs->free ? obj->data.fs->free :
@@ -4199,19 +4214,36 @@ static void generate_text_internal(char *p, int p_max_size,
? obj->data.fs->free : obj->data.fs->avail), p, 255); ? obj->data.fs->free : obj->data.fs->avail), p, 255);
} }
} }
#ifdef X11
OBJ(fs_bar_free) { OBJ(fs_bar_free) {
if (obj->data.fs != NULL) { if (obj->data.fs != NULL) {
if (obj->data.fs->size == 0) { if (obj->data.fs->size == 0) {
new_bar(p, obj->data.fsbar.w, obj->data.fsbar.h, 255); #ifdef X11
if(output_methods & TO_X) {
new_bar(p, obj->data.fsbar.w, obj->data.fsbar.h, 255);
}else{
#endif /* X11 */
if(!obj->data.fsbar.w) obj->data.fsbar.w = DEFAULT_BAR_WIDTH_NO_X;
new_bar_in_shell(p, p_max_size, 100, obj->data.fsbar.w);
#ifdef X11
}
#endif /* X11 */
} else { } else {
new_bar(p, obj->data.fsbar.w, obj->data.fsbar.h, #ifdef X11
(int) (obj->data.fsbar.fs->avail * 255 / if(output_methods & TO_X) {
obj->data.fs->size)); new_bar(p, obj->data.fsbar.w, obj->data.fsbar.h,
(int) (obj->data.fsbar.fs->avail * 255 /
obj->data.fs->size));
}else{
#endif /* X11 */
if(!obj->data.fsbar.w) obj->data.fsbar.w = DEFAULT_BAR_WIDTH_NO_X;
new_bar_in_shell(p, p_max_size,
(int) (obj->data.fsbar.fs->avail * 100 / obj->data.fs->size), obj->data.fsbar.w);
#ifdef X11
}
#endif /* X11 */
} }
} }
} }
#endif
OBJ(fs_used_perc) { OBJ(fs_used_perc) {
if (obj->data.fs != NULL) { if (obj->data.fs != NULL) {
int val = 0; int val = 0;

View File

@@ -57,7 +57,7 @@ enum text_object_type {
OBJ_battery_percent, OBJ_battery_percent,
#ifdef X11 #ifdef X11
OBJ_battery_bar, OBJ_battery_bar,
#endif #endif /* X11 */
OBJ_battery_short, OBJ_battery_short,
#endif /* !__OpenBSD__ */ #endif /* !__OpenBSD__ */
OBJ_buffers, OBJ_buffers,
@@ -83,7 +83,7 @@ enum text_object_type {
OBJ_cpugauge, OBJ_cpugauge,
OBJ_cpugraph, OBJ_cpugraph,
OBJ_loadgraph, OBJ_loadgraph,
#endif #endif /* X11 */
OBJ_diskio, OBJ_diskio,
OBJ_diskio_read, OBJ_diskio_read,
OBJ_diskio_write, OBJ_diskio_write,
@@ -91,12 +91,12 @@ enum text_object_type {
OBJ_diskiograph, OBJ_diskiograph,
OBJ_diskiograph_read, OBJ_diskiograph_read,
OBJ_diskiograph_write, OBJ_diskiograph_write,
#endif #endif /* X11 */
OBJ_downspeed, OBJ_downspeed,
OBJ_downspeedf, OBJ_downspeedf,
#ifdef X11 #ifdef X11
OBJ_downspeedgraph, OBJ_downspeedgraph,
#endif #endif /* X11 */
OBJ_else, OBJ_else,
OBJ_endif, OBJ_endif,
OBJ_eval, OBJ_eval,
@@ -111,15 +111,13 @@ enum text_object_type {
OBJ_execibar, OBJ_execibar,
OBJ_execigraph, OBJ_execigraph,
OBJ_execigauge, OBJ_execigauge,
#endif #endif /* X11 */
OBJ_execp, OBJ_execp,
OBJ_execpi, OBJ_execpi,
OBJ_freq, OBJ_freq,
OBJ_freq_g, OBJ_freq_g,
#ifdef X11
OBJ_fs_bar, OBJ_fs_bar,
OBJ_fs_bar_free, OBJ_fs_bar_free,
#endif
OBJ_fs_free, OBJ_fs_free,
OBJ_fs_free_perc, OBJ_fs_free_perc,
OBJ_fs_size, OBJ_fs_size,
@@ -451,12 +449,12 @@ struct text_object {
char *fmt; /* time display formatting */ char *fmt; /* time display formatting */
} tztime; } tztime;
#ifdef X11
struct { struct {
struct fs_stat *fs; struct fs_stat *fs;
int w, h; int w, h;
} fsbar; /* 3 */ } fsbar; /* 3 */
#ifdef X11
struct { struct {
int l; int l;
int w, h; int w, h;