diff options
| author | Mikhail Osipov <mike.osipov@gmail.com> | 2023-11-06 11:00:52 +0300 |
|---|---|---|
| committer | Mikhail Osipov <mike.osipov@gmail.com> | 2023-11-06 11:00:52 +0300 |
| commit | babbbb063fc76995d7b645893233227a2082fb56 (patch) | |
| tree | 5f4528c3d18789add619a74990b1d6cd86fa8598 /main.c | |
| parent | a82b8358b0c0fe43ec4dc023b789d98cc95240c5 (diff) | |
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 26 |
1 files changed, 20 insertions, 6 deletions
@@ -10,10 +10,11 @@ #include <assert.h> #include <ctype.h> #include <stdio.h> +#include <time.h> #include <err.h> #define TOPMEMCOUNT 8 -#define TOOLFONT "Terminus" +#define TOOLFONT "Roboto Mono" struct proc_entry { char *name; @@ -99,7 +100,7 @@ static void print_battery_status(void) fp = fmemopen(status, sizeof(status), "w"); if (! strcasecmp("charging", readline(SYSPATH, "status"))) - fprintf(fp, "%s ", charging); + fprintf(fp, "%s", charging); int capacity = atoi(readline(SYSPATH, "capacity")); @@ -110,7 +111,7 @@ static void print_battery_status(void) fflush(fp); - printf(", bat: %s", status); + printf(" bat:%s", status); readline(NULL, NULL); @@ -275,17 +276,29 @@ int main(int argc, char *argv[]) if (sysinfo(&si) < 0) return 1; +#ifdef XFCE printf("<txt>"); +#endif - printf("used: %ld", (si.totalram - si.freeram) * si.mem_unit >> 20); - printf(", free: %ld", si.freeram * si.mem_unit >> 20); + printf("used:%ld", (si.totalram - si.freeram) * si.mem_unit >> 20); + printf(" free:%ld", si.freeram * si.mem_unit >> 20); #if 0 printf(", swap: %d", (si.totalswap - si.freeswap) * si.mem_unit >> 10); #endif - printf(", procs: %d", si.procs); + printf(" procs:%d", si.procs); print_battery_status(); + time_t now = time(NULL); + struct tm *tm = localtime(&now); + char buf[64]; + strftime(buf, sizeof(buf), "%H:%M", tm); + + printf(" [%s]", buf); + +#ifndef XFCE + printf("\n"); +#else printf("</txt>\n"); printf("<tool><span font_family=\"" TOOLFONT "\">"); @@ -293,6 +306,7 @@ int main(int argc, char *argv[]) print_top_memory_usage(); printf("</span></tool>\n"); +#endif return 0; } |
