1
0
Fork 0
forked from murx/murx

Removed hostname from the status bar since we have a hostname in all window names.

This commit is contained in:
Johannes Findeisen 2026-11-15 23:43:02 +01:00
commit fa93f20f69
2 changed files with 7 additions and 21 deletions

View file

@ -164,8 +164,7 @@ Hard-coded:
- Status on top by default (`-s bottom` moves it), default background, foreground `colour12`. The palette mirrors - Status on top by default (`-s bottom` moves it), default background, foreground `colour12`. The palette mirrors
`~/.tmux.conf`. `~/.tmux.conf`.
- `[moerx]` on the left (`moerx` in `colour14`, brackets `colour12`). - `[moerx]` on the left (`moerx` in `colour14`, brackets `colour12`).
- `[host] HH:MM:SS` on the right (`host` in `colour14`, brackets and clock - `HH:MM:SS` on the right in `colour12`, refreshed every second.
`colour12`), refreshed every second.
- Window list right-aligned: current name `colour11`, other names `colour12`, - Window list right-aligned: current name `colour11`, other names `colour12`,
separators/flags `colour14`. separators/flags `colour14`.
- Pane borders are thin box-drawing lines (`─`, `│`, `┬`, `┼`, ...) in - Pane borders are thin box-drawing lines (`─`, `│`, `┬`, `┼`, ...) in

25
moerx.c
View file

@ -1707,12 +1707,8 @@ static void draw_labels(Grid *g, Layout *l, Window *win) {
draw_labels(g, l->b, win); draw_labels(g, l->b, win);
} }
static void status_right_draw(Grid *g, int rx, int y, const char *host, static void status_right_draw(Grid *g, int rx, int y, const char *clock) {
const char *clock) { int px = draw_text(g, rx, y, " ", P_STATUS, DEFAULT_COLOR, 0);
int px = draw_text(g, rx, y, " [", P_STATUS, DEFAULT_COLOR, 0);
px = draw_text(g, px, y, host, P_ACCENT, DEFAULT_COLOR, 0);
px = draw_text(g, px, y, "]", P_STATUS, DEFAULT_COLOR, 0);
px = draw_text(g, px, y, " ", P_STATUS, DEFAULT_COLOR, 0);
px = draw_text(g, px, y, clock, P_STATUS, DEFAULT_COLOR, 0); px = draw_text(g, px, y, clock, P_STATUS, DEFAULT_COLOR, 0);
draw_text(g, px, y, " ", P_STATUS, DEFAULT_COLOR, 0); draw_text(g, px, y, " ", P_STATUS, DEFAULT_COLOR, 0);
} }
@ -1737,26 +1733,17 @@ static void status_draw(Grid *g, Session *s, Client *c) {
int left_len = x; int left_len = x;
if (left_len > 20) left_len = 20; if (left_len > 20) left_len = 20;
char host[256];
if (gethostname(host, sizeof host) < 0) snprintf(host, sizeof host, "localhost");
host[sizeof host - 1] = '\0';
char *dot = strchr(host, '.');
if (dot) *dot = '\0';
time_t t = time(NULL); time_t t = time(NULL);
struct tm tmv; struct tm tmv;
localtime_r(&t, &tmv); localtime_r(&t, &tmv);
char clockbuf[32]; char clockbuf[32];
strftime(clockbuf, sizeof clockbuf, "%H:%M:%S", &tmv); strftime(clockbuf, sizeof clockbuf, "%H:%M:%S", &tmv);
char right[256]; int right_len = text_width(clockbuf) + 2;
snprintf(right, sizeof right, " [%s] %s ", host, clockbuf);
if ((int)strlen(right) > 50) right[50] = '\0';
int right_len = text_width(right);
if (right_len > s->w) right_len = s->w; if (right_len > s->w) right_len = s->w;
int rx = s->w - right_len; int rx = s->w - right_len;
if (rx < 0) rx = 0; if (rx < 0) rx = 0;
status_right_draw(g, rx, y, host, clockbuf); status_right_draw(g, rx, y, clockbuf);
int total = 0; int total = 0;
for (Window *w = s->windows; w; w = w->next) { for (Window *w = s->windows; w; w = w->next) {
@ -1814,8 +1801,8 @@ static void status_draw(Grid *g, Session *s, Client *c) {
} }
} }
/* keep host/time visible even if a message or window list is long */ /* keep the clock visible even if a message or window list is long */
status_right_draw(g, rx, y, host, clockbuf); status_right_draw(g, rx, y, clockbuf);
} }
static void menu_draw(Grid *g, Session *s, Client *c) { static void menu_draw(Grid *g, Session *s, Client *c) {