1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-02-02 12:08:33 +00:00

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}
Processes: $processes Running: $running_processes
File systems:
/ ${fs_used /}/${fs_size /}
/ ${fs_used /}/${fs_size /} ${fs_bar 6 /}
Networking:
Up: ${upspeed eth0} - Down: ${downspeed eth0}
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;
free(buf);
}
#endif
#endif /* X11 */
END OBJ(diskio, INFO_DISKIO)
obj->data.diskio = prepare_diskio_stat(dev_name(arg));
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));
if (buf)
free(buf);
#endif
#endif /* X11 */
END OBJ(color, 0)
#ifdef X11
if (output_methods & TO_X) {
@ -1563,7 +1563,7 @@ static struct text_object *construct_text_object(const char *s,
#ifdef X11
END OBJ(font, 0)
obj->data.s = scan_font(arg);
#endif
#endif /* X11 */
END OBJ(conky_version, 0)
END OBJ(conky_build_date, 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);
obj->data.net = get_net_stat(buf);
free(buf);
#endif
#endif /* X11 */
END OBJ(else, 0)
obj_be_ifblock_else(ifblock_opaque, obj);
END OBJ(endif, 0)
@ -1656,7 +1656,7 @@ static struct text_object *construct_text_object(const char *s,
} else {
obj->data.execi.cmd = strndup(arg + n, text_buffer_size);
}
#endif
#endif /* X11 */
END OBJ(execi, 0)
int n;
@ -1711,11 +1711,10 @@ static struct text_object *construct_text_object(const char *s,
obj->data.s = strndup("", text_buffer_size);
}
#endif
#ifdef X11
END OBJ(fs_bar, INFO_FS)
SIZE_DEFAULTS(bar);
arg = scan_bar(arg, &obj->data.fsbar.w, &obj->data.fsbar.h);
if (arg) {
if (arg) {
while (isspace(*arg)) {
arg++;
}
@ -1741,7 +1740,6 @@ static struct text_object *construct_text_object(const char *s,
}
obj->data.fsbar.fs = prepare_fs_stat(arg);
#endif
END OBJ(fs_free, INFO_FS)
if (!arg) {
arg = "/";
@ -4152,19 +4150,36 @@ static void generate_text_internal(char *p, int p_max_size,
timed_thread_unlock(mail->p_timed_thread);
}
}
#ifdef X11
OBJ(fs_bar) {
if (obj->data.fs != NULL) {
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 {
new_bar(p, obj->data.fsbar.w, obj->data.fsbar.h,
(int) (255 - obj->data.fsbar.fs->avail * 255 /
obj->data.fs->size));
#ifdef X11
if(output_methods & TO_X) {
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) {
if (obj->data.fs != NULL) {
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);
}
}
#ifdef X11
OBJ(fs_bar_free) {
if (obj->data.fs != NULL) {
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 {
new_bar(p, obj->data.fsbar.w, obj->data.fsbar.h,
(int) (obj->data.fsbar.fs->avail * 255 /
obj->data.fs->size));
#ifdef X11
if(output_methods & TO_X) {
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) {
if (obj->data.fs != NULL) {
int val = 0;

View File

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