Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bandwidth2: add configurable colors #517

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 7 additions & 4 deletions bandwidth2/bandwidth2.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <unistd.h>
#include <getopt.h>

#define RED "#FF7373"
#define ORANGE "#FFA500"
char RED[] = "#FF7373";
char ORANGE[] = "#FFA500";

typedef unsigned long long int ulli;

Expand Down Expand Up @@ -82,11 +82,14 @@ void display(int const unit, int const divisor,
double b, int const warning, int const critical)
{
char fmtstr[7];
char* envvar;

if (critical != 0 && b > critical) {
printf("<span fallback='true' color='%s'>", RED);
envvar = getenv("RED");
printf("<span fallback='true' color='%s'>", envvar ? envvar : RED);
} else if (warning != 0 && b > warning) {
printf("<span fallback='true' color='%s'>", ORANGE);
envvar = getenv("ORANGE");
printf("<span fallback='true' color='%s'>", envvar ? envvar : ORANGE);
} else {
printf("<span fallback='true'>");
}
Expand Down