Compare commits
5 Commits
61a2c42d12
...
c1e9069aa1
Author | SHA1 | Date |
---|---|---|
Michael Stapelberg | c1e9069aa1 | |
Murray Fordyce | cb516c2df3 | |
nia | 6094acde02 | |
Sepherosa Ziehau | 28399bf846 | |
sepherosa | f757ee415a |
|
@ -511,7 +511,7 @@ int main(int argc, char *argv[]) {
|
|||
break;
|
||||
case 'h':
|
||||
printf("i3status " I3STATUS_VERSION " © 2008 Michael Stapelberg and contributors\n"
|
||||
"Syntax: %s [-c <configfile>] [-h] [-v]\n",
|
||||
"Syntax: %s [-c <configfile>] [-h] [-v] [--run-once]\n",
|
||||
argv[0]);
|
||||
return 0;
|
||||
break;
|
||||
|
|
|
@ -9,11 +9,11 @@ i3status - Generates a status line for i3bar, dzen2, xmobar or lemonbar
|
|||
|
||||
== SYNOPSIS
|
||||
|
||||
i3status [-c configfile] [-h] [-v]
|
||||
i3status [-c configfile] [-h] [-v] [--run-once]
|
||||
|
||||
== OPTIONS
|
||||
|
||||
-c::
|
||||
-c --config::
|
||||
Specifies an alternate configuration file path. By default, i3status looks for
|
||||
configuration files in the following order:
|
||||
|
||||
|
@ -22,6 +22,16 @@ configuration files in the following order:
|
|||
3. ~/.i3status.conf
|
||||
4. /etc/i3status.conf
|
||||
|
||||
-h --help::
|
||||
Print the verison and a minimal syntax.
|
||||
|
||||
-v --version::
|
||||
Print the version and any build configuration.
|
||||
|
||||
--run-once::
|
||||
Only run once instead of looping.
|
||||
|
||||
|
||||
== DESCRIPTION
|
||||
|
||||
i3status is a small program for generating a status bar for i3bar, dzen2,
|
||||
|
|
|
@ -39,6 +39,13 @@
|
|||
#include "i3status.h"
|
||||
|
||||
struct cpu_usage {
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
|
||||
long user;
|
||||
long nice;
|
||||
long system;
|
||||
long idle;
|
||||
long total;
|
||||
#else
|
||||
int user;
|
||||
int nice;
|
||||
int system;
|
||||
|
@ -47,6 +54,7 @@ struct cpu_usage {
|
|||
int spin;
|
||||
#endif
|
||||
int total;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(__linux__)
|
||||
|
@ -66,7 +74,12 @@ void print_cpu_usage(cpu_usage_ctx_t *ctx) {
|
|||
const char *walk;
|
||||
char *outwalk = ctx->buf;
|
||||
struct cpu_usage curr_all = {0, 0, 0, 0, 0};
|
||||
int diff_idle, diff_total, diff_usage;
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
|
||||
long diff_idle, diff_total;
|
||||
#else
|
||||
int diff_idle, diff_total;
|
||||
#endif
|
||||
int diff_usage;
|
||||
bool colorful_output = false;
|
||||
|
||||
#if defined(__linux__)
|
||||
|
@ -153,6 +166,9 @@ void print_cpu_usage(cpu_usage_ctx_t *ctx) {
|
|||
curr_all.user = cp_time[CP_USER];
|
||||
curr_all.nice = cp_time[CP_NICE];
|
||||
curr_all.system = cp_time[CP_SYS];
|
||||
#if defined(__DragonFly__)
|
||||
curr_all.system += cp_time[CP_INTR];
|
||||
#endif
|
||||
curr_all.idle = cp_time[CP_IDLE];
|
||||
#if defined(__OpenBSD__)
|
||||
curr_all.spin = cp_time[CP_SPIN];
|
||||
|
|
|
@ -73,9 +73,17 @@ static bool below_threshold(struct statvfs buf, const char *prefix_type, const c
|
|||
} else if (strcasecmp(threshold_type, "percentage_avail") == 0) {
|
||||
return 100.0 * (double)buf.f_bavail / (double)buf.f_blocks < low_threshold;
|
||||
} else if (strcasecmp(threshold_type, "bytes_free") == 0) {
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__APPLE__)
|
||||
return (double)buf.f_bsize * (double)buf.f_bfree < low_threshold;
|
||||
#else
|
||||
return (double)buf.f_frsize * (double)buf.f_bfree < low_threshold;
|
||||
#endif
|
||||
} else if (strcasecmp(threshold_type, "bytes_avail") == 0) {
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__APPLE__)
|
||||
return (double)buf.f_bsize * (double)buf.f_bavail < low_threshold;
|
||||
#else
|
||||
return (double)buf.f_frsize * (double)buf.f_bavail < low_threshold;
|
||||
#endif
|
||||
} else if (threshold_type[0] != '\0' && strncasecmp(threshold_type + 1, "bytes_", strlen("bytes_")) == 0) {
|
||||
uint64_t base = strcasecmp(prefix_type, "decimal") == 0 ? DECIMAL_BASE : BINARY_BASE;
|
||||
double factor = 1;
|
||||
|
@ -190,10 +198,17 @@ void print_disk_info(disk_info_ctx_t *ctx) {
|
|||
char string_percentage_used[STRING_SIZE];
|
||||
char string_percentage_avail[STRING_SIZE];
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__APPLE__)
|
||||
print_bytes_human(string_free, (uint64_t)buf.f_bsize * (uint64_t)buf.f_bfree, ctx->prefix_type);
|
||||
print_bytes_human(string_used, (uint64_t)buf.f_bsize * ((uint64_t)buf.f_blocks - (uint64_t)buf.f_bfree), ctx->prefix_type);
|
||||
print_bytes_human(string_total, (uint64_t)buf.f_bsize * (uint64_t)buf.f_blocks, ctx->prefix_type);
|
||||
print_bytes_human(string_avail, (uint64_t)buf.f_bsize * (uint64_t)buf.f_bavail, ctx->prefix_type);
|
||||
#else
|
||||
print_bytes_human(string_free, (uint64_t)buf.f_frsize * (uint64_t)buf.f_bfree, ctx->prefix_type);
|
||||
print_bytes_human(string_used, (uint64_t)buf.f_frsize * ((uint64_t)buf.f_blocks - (uint64_t)buf.f_bfree), ctx->prefix_type);
|
||||
print_bytes_human(string_total, (uint64_t)buf.f_frsize * (uint64_t)buf.f_blocks, ctx->prefix_type);
|
||||
print_bytes_human(string_avail, (uint64_t)buf.f_frsize * (uint64_t)buf.f_bavail, ctx->prefix_type);
|
||||
#endif
|
||||
snprintf(string_percentage_free, STRING_SIZE, "%.01f%s", 100.0 * (double)buf.f_bfree / (double)buf.f_blocks, pct_mark);
|
||||
snprintf(string_percentage_used_of_avail, STRING_SIZE, "%.01f%s", 100.0 * (double)(buf.f_blocks - buf.f_bavail) / (double)buf.f_blocks, pct_mark);
|
||||
snprintf(string_percentage_used, STRING_SIZE, "%.01f%s", 100.0 * (double)(buf.f_blocks - buf.f_bfree) / (double)buf.f_blocks, pct_mark);
|
||||
|
|
|
@ -19,6 +19,12 @@ void print_file_contents(file_contents_ctx_t *ctx) {
|
|||
char *outwalk = ctx->buf;
|
||||
char *buf = scalloc(ctx->max_chars * sizeof(char) + 1);
|
||||
|
||||
if (ctx->path == NULL) {
|
||||
OUTPUT_FULL_TEXT("error: path not configured");
|
||||
free(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
char *abs_path = resolve_tilde(ctx->path);
|
||||
int fd = open(abs_path, O_RDONLY);
|
||||
free(abs_path);
|
||||
|
|
|
@ -330,7 +330,7 @@ void print_volume(volume_ctx_t *ctx) {
|
|||
|
||||
if (vinfo.un.ord) {
|
||||
START_COLOR("color_degraded");
|
||||
fmt = fmt_muted;
|
||||
ctx->fmt = ctx->fmt_muted;
|
||||
pbval = 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue