aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2019-07-05 15:31:37 +0200
committerGerd Hoffmann <kraxel@redhat.com>2019-07-05 15:31:37 +0200
commit71960d285d047c73be334655b0ea2a6d32279948 (patch)
tree7951db67d38ed4107fee1abb2c5013dc9173771b
parent7c67952ba17625c12c00089424d55837a07f2d74 (diff)
downloadgterm-71960d285d047c73be334655b0ea2a6d32279948.tar.gz
gload: color option
-rw-r--r--README.md2
-rw-r--r--gload.c11
2 files changed, 11 insertions, 2 deletions
diff --git a/README.md b/README.md
index 8fcfe75..4d36eca 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ not work with wayland. The x11 server side font rendering comes to mind
for example. Also any charset quirks dating back to the early x11 days,
before unicode and utf-8 did exist.
-## gload
+# gload
Bundled with gterm is the small gload utility, which is a xload style
load average monitor.
diff --git a/gload.c b/gload.c
index 1e4d373..de3049b 100644
--- a/gload.c
+++ b/gload.c
@@ -18,12 +18,15 @@
#define GLOAD_CFG_KEY_LABEL "label"
#define GLOAD_CFG_KEY_UPDATE "update"
+#define GLOAD_CFG_KEY_HIGHLIGHT "highlight"
static const gcfg_opt gload_opts[] = {
{ .opt = "label", .key = GLOAD_CFG_KEY_LABEL },
{ .opt = "update", .key = GLOAD_CFG_KEY_UPDATE },
{ .opt = "name", .key = GCFG_KEY_PROFILE },
{ .opt = "class", .key = GCFG_KEY_PROFILE },
+ { .opt = "hl", .key = GLOAD_CFG_KEY_HIGHLIGHT },
+ { .opt = "highlight", .key = GLOAD_CFG_KEY_HIGHLIGHT },
};
/* ------------------------------------------------------------------------ */
@@ -124,13 +127,19 @@ static gboolean gload_draw(GtkWidget *widget, cairo_t *cr, gpointer data)
gload *gl = data;
GtkStyleContext *context;
GdkRGBA normal, dimmed;
+ const char *highlight;
guint width, height, i, idx, max;
context = gtk_widget_get_style_context(widget);
width = gtk_widget_get_allocated_width(widget);
height = gtk_widget_get_allocated_height(widget);
- gtk_style_context_get_color(context, GTK_STATE_FLAG_NORMAL, &normal);
+ highlight = gcfg_get(gl->cfg, GLOAD_CFG_KEY_HIGHLIGHT);
+ if (highlight) {
+ gdk_rgba_parse(&normal, highlight);
+ } else {
+ gtk_style_context_get_color(context, GTK_STATE_FLAG_NORMAL, &normal);
+ }
dimmed = normal;
normal.alpha = 1.0;
dimmed.alpha = 0.6;