commit 2b044aff23a3dfafa4281fbb566930bc8383e8c5
Author: MrJensK <jens.se@icloud.com>
AuthorDate: Tue May 12 21:34:36 2026 +0200
Commit: MrJensK <jens.se@icloud.com>
CommitDate: Tue May 12 21:34:36 2026 +0200
update
---
README.md | 40 ++++++++++++++++++++++++++++++++++++++++
default_sxbarc | 4 ++++
src/defs.h | 2 ++
src/parser.c | 6 ++++++
src/sxbar.c | 10 +++++++---
5 files changed, 59 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index a5bd9d1..9755449 100644
--- a/README.md
+++ b/README.md
@@ -21,3 +21,43 @@ This patch enhances **sxbar** so that workspace boxes on each monitor and only s
- Each sxbar instance displays accurate workspace status for its own screen.
- Workspace boxes are informative and reflect the window layout on each monitor.
+
+## Version display support
+
+This update adds optional version information to the bar.
+
+### Changes
+- Added new global config keys in `default_sxbarc`:
+ - `show_version : true`
+ - `version_text : sxbar ver. 1.1`
+- Parser now supports `show_version` and `version_text` in the config file.
+- `sxbar` now draws the version text only when `show_version` is enabled.
+- Default initialization now enables version display and uses the `SXBAR_VERSION` string.
+
+### Result
+
+- The bar can show a custom version string at the right edge.
+- Version output is configurable and can be disabled without changing the code.
+
+## Config file and script modules
+
+A new config file format is now supported via `default_sxbarc`.
+
+### Highlights
+- Global options can be set in the config file.
+- Custom script modules are supported using `custom : label : "command or script" : interval`.
+- Bash commands, external script paths and shell pipelines can be used for dynamic status output.
+
+### Example
+- `custom : temp : "sensors | grep 'Package' | awk '{print $4}'" : 5`
+- `custom : network : "~/.config/sxbar/scripts/network.sh" : 5`
+
+### Result
+
+- Users can configure sxbar without recompiling.
+- Bash scripts and shell commands can produce bar text dynamically.
+
+## Disk footprint
+
+- `sxbar` is very lightweight: the compiled binary is about 36 KB.
+- The source tree is also small, so `sxbar` is ideal for minimal Xorg setups.
diff --git a/default_sxbarc b/default_sxbarc
index b98d34c..160e44e 100644
--- a/default_sxbarc
+++ b/default_sxbarc
@@ -2,6 +2,10 @@
# Format: key : value
# Colours accept hex (#rrggbb) or X colour names
+# Global settings
+show_version : true
+version_text : sxbar ver. 1.1
+
# Appearance
height : 20
bottom_bar : false
diff --git a/src/defs.h b/src/defs.h
index 2bcfea2..bd6c25e 100644
--- a/src/defs.h
+++ b/src/defs.h
@@ -30,6 +30,8 @@ typedef struct Config {
unsigned long foreground_colour;
unsigned long border_colour;
char *font;
+ int show_version;
+ char *version_text;
Module *modules;
int module_count;
int max_modules;
diff --git a/src/parser.c b/src/parser.c
index b1c464f..6a43b5c 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -169,6 +169,12 @@ int parse_config(Config *cfg)
strip_comment(rest);
free(cfg->font);
cfg->font = strdup(rest);
+ } else if (!strcmp(key, "show_version")) {
+ cfg->show_version = parse_bool(rest);
+ } else if (!strcmp(key, "version_text")) {
+ strip_comment(rest);
+ free(cfg->version_text);
+ cfg->version_text = strdup(rest);
} else if (!strcmp(key, "module")) {
/* module : name : enabled : interval */
char *p1 = strchr(rest, ':');
diff --git a/src/sxbar.c b/src/sxbar.c
index 5063ca1..faa9b34 100644
--- a/src/sxbar.c
+++ b/src/sxbar.c
@@ -292,7 +292,7 @@ static void draw_bar_into(Drawable draw, int monitor_index)
strlen(config.modules[i].cached_output)) +
mod_sp;
}
- int ver_w = XTextWidth(font, SXBAR_VERSION, strlen(SXBAR_VERSION));
+ int ver_w = config.show_version ? XTextWidth(font, config.version_text, strlen(config.version_text)) : 0;
int mx = w - total_mw - ver_w - 2 * config.text_padding - 2 * pad;
for (int i = 0; i < config.module_count; i++) {
@@ -306,8 +306,10 @@ static void draw_bar_into(Drawable draw, int monitor_index)
}
/* version */
- int vx = w - ver_w - config.text_padding - pad;
- XDrawString(dpy, draw, gc, vx, text_y, SXBAR_VERSION, strlen(SXBAR_VERSION));
+ if (config.show_version) {
+ int vx = w - ver_w - config.text_padding - pad;
+ XDrawString(dpy, draw, gc, vx, text_y, config.version_text, strlen(config.version_text));
+ }
}
static void redraw_monitor(int i)
@@ -395,6 +397,8 @@ void init_defaults(void)
config.foreground_colour = parse_col("#7abccd");
config.border_colour = parse_col("#005577");
config.font = strdup("fixed");
+ config.show_version = True;
+ config.version_text = strdup(SXBAR_VERSION);
init_modules();
}