Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions i3status.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ int main(int argc, char *argv[]) {
CFG_STR("format", "%usage", CFGF_NONE),
CFG_STR("format_above_threshold", NULL, CFGF_NONE),
CFG_STR("format_above_degraded_threshold", NULL, CFGF_NONE),
CFG_STR("format_usage", "%02d%s", CFGF_NONE),
CFG_STR("path", "/proc/stat", CFGF_NONE),
CFG_FLOAT("max_threshold", 95, CFGF_NONE),
CFG_FLOAT("degraded_threshold", 90, CFGF_NONE),
Expand Down Expand Up @@ -922,6 +923,7 @@ int main(int argc, char *argv[]) {
.format = cfg_getstr(sec, "format"),
.format_above_threshold = cfg_getstr(sec, "format_above_threshold"),
.format_above_degraded_threshold = cfg_getstr(sec, "format_above_degraded_threshold"),
.format_usage = cfg_getstr(sec, "format_usage"),
.path = cfg_getstr(sec, "path"),
.max_threshold = cfg_getfloat(sec, "max_threshold"),
.degraded_threshold = cfg_getfloat(sec, "degraded_threshold"),
Expand Down
1 change: 1 addition & 0 deletions include/i3status.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ typedef struct {
const char *format;
const char *format_above_threshold;
const char *format_above_degraded_threshold;
const char *format_usage;
const char *path;
const float max_threshold;
const float degraded_threshold;
Expand Down
5 changes: 5 additions & 0 deletions man/i3status.man
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,9 @@ getting higher than the configured threshold. Defaults to 90. The output format
when above degraded threshold can be customized with
+format_above_degraded_threshold+.

CPU usage is by default displayed as a percentage zero-padded to 2 digits. If
you want the usage percentage to be shown in another format, use +format_usage+.

For displaying the Nth CPU usage, you can use the %cpu<N> format string,
starting from %cpu0. This feature is currently not supported in FreeBSD.

Expand All @@ -466,6 +469,8 @@ starting from %cpu0. This feature is currently not supported in FreeBSD.

*Example format_above_degraded_threshold*: +Warning above degraded threshold: %usage+

*Example format_usage*: +"%02d%s"+

=== Memory

Gets the memory usage from system on a Linux system from +/proc/meminfo+. Other
Expand Down
4 changes: 2 additions & 2 deletions src/print_cpu_usage.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void print_cpu_usage(cpu_usage_ctx_t *ctx) {
*(outwalk++) = *walk;

} else if (BEGINS_WITH(walk + 1, "usage")) {
outwalk += sprintf(outwalk, "%02d%s", diff_usage, pct_mark);
outwalk += sprintf(outwalk, ctx->format_usage, diff_usage, pct_mark);
walk += strlen("usage");
}
#if defined(__linux__)
Expand All @@ -217,7 +217,7 @@ void print_cpu_usage(cpu_usage_ctx_t *ctx) {
int cpu_diff_idle = curr_cpus[number].idle - prev_cpus[number].idle;
int cpu_diff_total = curr_cpus[number].total - prev_cpus[number].total;
int cpu_diff_usage = (cpu_diff_total ? (1000 * (cpu_diff_total - cpu_diff_idle) / cpu_diff_total + 5) / 10 : 0);
outwalk += sprintf(outwalk, "%02d%s", cpu_diff_usage, pct_mark);
outwalk += sprintf(outwalk, ctx->format_usage, cpu_diff_usage, pct_mark);
}
walk += length;
}
Expand Down