linux-qubasis
linux oasis port as a qubes template
git clone https://9o.is/git/linux-qubasis.git
commit 9d264411b1d77ba923d682bec3b9560d94d4dc93 parent c9a80c4a3578e12987784f455661fe2808a866fe Author: Jul <jul@9o.is> Date: Sun, 20 Jul 2025 17:45:21 -0400 minimize ui of dvtm status bar even further Diffstat:
| M | pkg/dvtm/config.h | | | 2 | ++ |
| M | pkg/dvtm/patches/0001-customize-personal-UI.patch | | | 168 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------- |
| M | pkg/dvtm/patches/0002-allow-focusing-left-right-fullscreen.patch | | | 6 | +++--- |
3 files changed, 121 insertions(+), 55 deletions(-)
diff --git a/pkg/dvtm/config.h b/pkg/dvtm/config.h @@ -44,6 +44,8 @@ static Color colors[] = { #define TAG_OCCUPIED (COLOR(DEFAULT) | A_NORMAL) /* curses attributes for not selected tags which with urgent windows */ #define TAG_URGENT (COLOR(DEFAULT) | A_NORMAL | A_BLINK) +/* curses attributes for the keybinding in status bar */ +#define KEYS_STATUS_ATTR (COLOR(BLUE) | A_BOLD | A_REVERSE) const char tags[][8] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; diff --git a/pkg/dvtm/patches/0001-customize-personal-UI.patch b/pkg/dvtm/patches/0001-customize-personal-UI.patch @@ -1,20 +1,22 @@ -From e8337ba61c92afc5e45f54b6c5ddf95d68f179c3 Mon Sep 17 00:00:00 2001 +From 9d84076cde117db8adec30c8e33e01cf52cf69b4 Mon Sep 17 00:00:00 2001 From: Jul <jul@qh.is> Date: Sat, 19 Jul 2025 14:05:33 -0400 -Subject: [PATCH] customize personal UI +Subject: [PATCH 1/2] customize personal UI --- - dvtm.c | 168 ++++++++++++++++++++++++++++----------------------------- - 1 file changed, 82 insertions(+), 86 deletions(-) + dvtm.c | 224 ++++++++++++++++++++++++++++++++++----------------------- + 1 file changed, 134 insertions(+), 90 deletions(-) diff --git a/dvtm.c b/dvtm.c -index 8382c83..79747d0 100644 +index 8382c83..3690acf 100644 --- a/dvtm.c +++ b/dvtm.c -@@ -324,74 +324,86 @@ showbar(void) { +@@ -322,87 +322,146 @@ showbar(void) { + bar.pos = bar.lastpos; + } - static void - drawbar(void) { +-static void +-drawbar(void) { - int sx, sy, x, y, width; - unsigned int occupied = 0, urgent = 0; - if (bar.pos == BAR_OFF) @@ -83,15 +85,31 @@ index 8382c83..79747d0 100644 - attrset(NORMAL_ATTR); - move(sy, sx); - wnoutrefresh(stdscr); -+ int sx, sy, x, y, width; -+ unsigned int occupied = 0, urgent = 0, total_clients = 0; ++static unsigned int ++total_visible_clients(void) { ++ unsigned int total = 0; ++ for (Client *c = clients; c; c = c->next) { ++ if (isvisible(c)) ++ total++; ++ } ++ return total; + } + + static int + show_border(void) { +- return (bar.pos != BAR_OFF) || (clients && clients->next); ++ return !isarrange(fullscreen) && total_visible_clients() > 1; ++} ++ ++static void ++drawbar(void) { ++ int sx, sy, x, y, width, len_lhs = 0, len_rhs = 0; ++ unsigned int occupied = 0, urgent = 0; ++ + if (bar.pos == BAR_OFF) + return; + + for (Client *c = clients; c; c = c->next) { -+ if (isvisible(c)) -+ total_clients++; -+ + occupied |= c->tags; + + if (c->urgent) @@ -101,73 +119,110 @@ index 8382c83..79747d0 100644 + getyx(stdscr, sy, sx); + move(bar.y, 0); + -+ if (sel) { -+ char t = '\0'; -+ unsigned int maxlen = screen.w / 2; ++ for (unsigned int i = 0; i < screen.w; ++i) { ++ addch(' '); ++ } + -+ if ((size_t)maxlen < sizeof(sel->title)) { -+ t = sel->title[maxlen]; -+ sel->title[maxlen] = '\0'; -+ } ++ unsigned int len_actual_title = sel ? strlen(sel->title) : 0; ++ unsigned int maxlen_title = screen.w / 2; ++ move(bar.y, 0); + -+ printw("%s", *sel->title ? sel->title : ""); -+ if (t) -+ sel->title[maxlen] = t; -+ } ++ if (!show_border()) ++ attrset(TAG_SEL); + -+ move(bar.y, screen.w / 2 + 1); -+ getyx(stdscr, y, x); -+ (void)y; ++ unsigned int len_title = 0; ++ for (unsigned int i = 0; i < len_actual_title; i++){ ++ if (i >= maxlen_title) break; ++ printw("%c", sel->title[i]); ++ len_title++; ++ } + -+ int maxwidth = screen.w - x - 16; -+ wchar_t wbuf[sizeof bar.text]; -+ size_t numchars = mbstowcs(wbuf, bar.text, sizeof bar.text); ++ attrset(NORMAL_ATTR); ++ len_lhs += len_title; + -+ if (numchars != (size_t)-1 && (width = wcswidth(wbuf, maxwidth)) != -1) { -+ int pos; -+ for (pos = 0; pos + width < maxwidth; pos++) -+ addch(' '); ++ unsigned int len_keys = keys[0] ? MAX_KEYS : 0; ++ if (len_keys) { ++ move(bar.y, screen.w - len_rhs - MAX_KEYS); ++ len_rhs += len_keys + 1; ++ attrset(KEYS_STATUS_ATTR); + -+ for (size_t i = 0; i < numchars; i++) { -+ pos += wcwidth(wbuf[i]); -+ if (pos > maxwidth) -+ break; -+ addnwstr(wbuf+i, 1); ++ for (unsigned int i = 0; i < MAX_KEYS - 1 && keys[i]; i++) { ++ if (keys[i] < ' ') ++ printw("^%c", 'A' - 1 + keys[i]); ++ else if (keys[i] <= '~') ++ printw("%c", keys[i]); + } + -+ clrtoeol(); ++ attrset(NORMAL_ATTR); + } + -+ if (sel && total_clients > 1) -+ printw(" [%d/%d]", sel->order, total_clients); ++ char hostname[256]; ++ unsigned int len_hostname = 0; ++ if (gethostname(hostname, sizeof(hostname)) == 0) { ++ len_hostname = strlen(hostname) + 2; ++ move(bar.y, screen.w - len_rhs - len_hostname); ++ len_rhs += len_hostname + 1; ++ printw("[%s]", hostname); ++ } + -+ unsigned int tag_position = 0; ++ unsigned int len_tags = 0; + for (unsigned int i = 0; i < LENGTH(tags); i++){ -+ move(bar.y, screen.w - tag_position - 1); ++ move(bar.y, screen.w - len_rhs - len_tags - 1); + + if (tagset[seltags] & (1 << i)) { + attrset(TAG_SEL); + printw("%s", tags[i]); -+ tag_position++; ++ len_tags++; + } else if (urgent & (1 << i)) { + attrset(TAG_URGENT); + printw("%s", tags[i]); -+ tag_position++; ++ len_tags++; + } else if (occupied & (1 << i)) { + attrset(TAG_OCCUPIED); + printw("%s", tags[i]); -+ tag_position++; ++ len_tags++; + } + } + ++ len_rhs += len_tags; + attrset(NORMAL_ATTR); ++ ++ char buffer_clients[8]; ++ unsigned int total_clients = total_visible_clients(); ++ unsigned int len_clients = !sel && total_clients == 0 ++ ? 0 : snprintf(buffer_clients, sizeof(buffer_clients), "[%d/%d]", sel->order, total_clients); ++ ++ if (len_clients) { ++ move(bar.y, screen.w - len_rhs - len_clients - 1); ++ len_rhs += len_clients + 1; ++ printw("%s", buffer_clients); ++ } ++ ++ move(bar.y, len_lhs + 1); ++ getyx(stdscr, y, x); ++ (void)y; ++ ++ int maxwidth = screen.w - len_lhs - len_rhs - 2; ++ wchar_t wbuf[sizeof bar.text]; ++ size_t numchars = mbstowcs(wbuf, bar.text, sizeof bar.text); ++ ++ if (numchars != (size_t)-1 && (width = wcswidth(wbuf, maxwidth)) != -1) { ++ int pos; ++ for (pos = 0; pos + width < maxwidth; pos++) ++ addch(' '); ++ ++ for (size_t i = 0; i < numchars; i++) { ++ pos += wcwidth(wbuf[i]); ++ if (pos > maxwidth) ++ break; ++ addnwstr(wbuf+i, 1); ++ } ++ } ++ + move(sy, sx); + wnoutrefresh(stdscr); } - static int -@@ -401,8 +413,7 @@ show_border(void) { - static void draw_border(Client *c) { - char t = '\0'; @@ -176,7 +231,7 @@ index 8382c83..79747d0 100644 if (!show_border()) return; -@@ -414,20 +425,6 @@ draw_border(Client *c) { +@@ -414,20 +473,6 @@ draw_border(Client *c) { wattrset(c->window, attrs); getyx(c->window, y, x); mvwhline(c->window, 0, 0, ACS_HLINE, c->w); @@ -197,7 +252,16 @@ index 8382c83..79747d0 100644 wmove(c->window, y, x); } -@@ -634,8 +631,7 @@ term_title_handler(Vt *term, const char *title) { +@@ -482,7 +527,7 @@ arrange(void) { + } + erase(); + attrset(NORMAL_ATTR); +- if (bar.fd == -1 && bar.autohide) { ++ if (bar.autohide) { + if ((!clients || !clients->next) && n == 1) + hidebar(); + else +@@ -634,8 +679,7 @@ term_title_handler(Vt *term, const char *title) { strncpy(c->title, title, sizeof(c->title) - 1); c->title[title ? sizeof(c->title) - 1 : 0] = '\0'; settitle(c); diff --git a/pkg/dvtm/patches/0002-allow-focusing-left-right-fullscreen.patch b/pkg/dvtm/patches/0002-allow-focusing-left-right-fullscreen.patch @@ -1,4 +1,4 @@ -From fffd5dccf957f42a6e85cffa56018ac348258865 Mon Sep 17 00:00:00 2001 +From cb686d9654aa0347291e4353b2b402b32ca7dac2 Mon Sep 17 00:00:00 2001 From: Jul <jul@qh.is> Date: Sat, 19 Jul 2025 20:49:03 -0400 Subject: [PATCH 2/2] allow focusing left/right fullscreen @@ -8,10 +8,10 @@ Subject: [PATCH 2/2] allow focusing left/right fullscreen 1 file changed, 2 deletions(-) diff --git a/dvtm.c b/dvtm.c -index 79747d0..e232f8b 100644 +index 3690acf..9011f84 100644 --- a/dvtm.c +++ b/dvtm.c -@@ -690,8 +690,6 @@ static Client* +@@ -738,8 +738,6 @@ static Client* get_client_by_coord(unsigned int x, unsigned int y) { if (y < way || y >= way+wah) return NULL;