sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 071c065179f28bae42bb876cf4bae4f680dd2baf
parent 1b7632929d73201194aefb8772df68b9459f52c2
Author: uint23 <abhinav.prsai@gmail.com>
Date:   Tue,  8 Apr 2025 21:52:42 +0100

floatingstatus - dwm statusbar customization

lets dwm statusbar to float with vertical and horizontal padding and
height

Diffstat:
Adwm.suckless.org/patches/floatingstatus/floatingstatus-20250408-cfb8627.diff | 282+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adwm.suckless.org/patches/floatingstatus/index.md | 22++++++++++++++++++++++
Adwm.suckless.org/patches/floatingstatus/screenshot.png | 0
3 files changed, 304 insertions(+), 0 deletions(-)

diff --git a/dwm.suckless.org/patches/floatingstatus/floatingstatus-20250408-cfb8627.diff b/dwm.suckless.org/patches/floatingstatus/floatingstatus-20250408-cfb8627.diff @@ -0,0 +1,282 @@ +From 74a90e7f249961c6d5d8f430a404d70628d6e3ea Mon Sep 17 00:00:00 2001 +From: uint23 <abhinav.prsai@gmail.com> +Date: Tue, 8 Apr 2025 17:33:20 +0100 +Subject: [PATCH] floating status bar patch + +--- + config.def.h | 6 ++ + dwm.c | 182 ++++++++++++++++++++++++++++----------------------- + 2 files changed, 106 insertions(+), 82 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 9efa774..4febd22 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -2,6 +2,11 @@ + + /* appearance */ + static const unsigned int borderpx = 1; /* border pixel of windows */ ++static const unsigned int barpadv = 10; /* bar vertical padding (from top)*/ ++static const unsigned int barpadh = 200; /* bar vertical padding (from top)*/ ++static const unsigned int barheight = 2; /* bar vertical padding (from top)*/ ++static const unsigned int barborder = 2; /* bar vertical padding (from top)*/ ++static const unsigned int floatbar = 1; /* 0 means bar won't float; float or dock the bar */ + static const unsigned int snap = 32; /* snap pixel */ + static const int showbar = 1; /* 0 means no bar */ + static const int topbar = 1; /* 0 means bottom bar */ +@@ -16,6 +21,7 @@ static const char *colors[][3] = { + /* fg bg border */ + [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, + [SchemeSel] = { col_gray4, col_cyan, col_cyan }, ++ [SchemeBar] = { NULL, NULL, col_cyan }, + }; + + /* tagging */ +diff --git a/dwm.c b/dwm.c +index 1443802..10fa1e8 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -58,7 +58,7 @@ + + /* enums */ + enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ +-enum { SchemeNorm, SchemeSel }; /* color schemes */ ++enum { SchemeNorm, SchemeSel, SchemeBar }; /* color schemes */ + enum { NetSupported, NetWMName, NetWMState, NetWMCheck, + NetWMFullscreen, NetActiveWindow, NetWMWindowType, + NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ +@@ -338,10 +338,10 @@ applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact) + if (*y + *h + 2 * c->bw <= m->wy) + *y = m->wy; + } +- if (*h < bh) +- *h = bh; +- if (*w < bh) +- *w = bh; ++ if (*h < bh + barheight) ++ *h = bh + barheight; ++ if (*w < bh + barheight) ++ *w = bh + barheight; + if (resizehints || c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) { + if (!c->hintsvalid) + updatesizehints(c); +@@ -563,13 +563,13 @@ configurenotify(XEvent *e) + sw = ev->width; + sh = ev->height; + if (updategeom() || dirty) { +- drw_resize(drw, sw, bh); ++ drw_resize(drw, sw, bh + barheight); + updatebars(); + for (m = mons; m; m = m->next) { + for (c = m->clients; c; c = c->next) + if (c->isfullscreen) + resizeclient(c, m->mx, m->my, m->mw, m->mh); +- XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh); ++ XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh + barheight); + } + focus(NULL); + arrange(NULL); +@@ -697,54 +697,57 @@ dirtomon(int dir) + void + drawbar(Monitor *m) + { +- int x, w, tw = 0; +- int boxs = drw->fonts->h / 9; +- int boxw = drw->fonts->h / 6 + 2; +- unsigned int i, occ = 0, urg = 0; +- Client *c; +- +- if (!m->showbar) +- return; +- +- /* draw status first so it can be overdrawn by tags later */ +- if (m == selmon) { /* status is only drawn on selected monitor */ +- drw_setscheme(drw, scheme[SchemeNorm]); +- tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ +- drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); +- } +- +- for (c = m->clients; c; c = c->next) { +- occ |= c->tags; +- if (c->isurgent) +- urg |= c->tags; +- } +- x = 0; +- for (i = 0; i < LENGTH(tags); i++) { +- w = TEXTW(tags[i]); +- drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); +- drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i); +- if (occ & 1 << i) +- drw_rect(drw, x + boxs, boxs, boxw, boxw, +- m == selmon && selmon->sel && selmon->sel->tags & 1 << i, +- urg & 1 << i); +- x += w; +- } +- w = TEXTW(m->ltsymbol); +- drw_setscheme(drw, scheme[SchemeNorm]); +- x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); +- +- if ((w = m->ww - tw - x) > bh) { +- if (m->sel) { +- drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); +- drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); +- if (m->sel->isfloating) +- drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); +- } else { +- drw_setscheme(drw, scheme[SchemeNorm]); +- drw_rect(drw, x, 0, w, bh, 1, 1); +- } +- } +- drw_map(drw, m->barwin, 0, 0, m->ww, bh); ++ int x, w, tw = 0; ++ int boxs = drw->fonts->h / 9; ++ int boxw = drw->fonts->h / 6 + 2; ++ unsigned int i, occ = 0, urg = 0; ++ Client *c; ++ ++ // Calculate the actual bar width depending on if it's floating ++ int barwidth = floatbar ? (m->ww - 2 * barpadh) : m->ww; ++ ++ if (!m->showbar) ++ return; ++ ++ /* draw status first so it can be overdrawn by tags later */ ++ if (m == selmon) { /* status is only drawn on selected monitor */ ++ drw_setscheme(drw, scheme[SchemeNorm]); ++ tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ ++ drw_text(drw, barwidth - tw, 0, tw, bh + barheight, 0, stext, 0); ++ } ++ ++ for (c = m->clients; c; c = c->next) { ++ occ |= c->tags; ++ if (c->isurgent) ++ urg |= c->tags; ++ } ++ x = 0; ++ for (i = 0; i < LENGTH(tags); i++) { ++ w = TEXTW(tags[i]); ++ drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); ++ drw_text(drw, x, 0, w, bh + barheight, lrpad / 2, tags[i], urg & 1 << i); ++ if (occ & 1 << i) ++ drw_rect(drw, x + boxs, boxs, boxw, boxw, ++ m == selmon && selmon->sel && selmon->sel->tags & 1 << i, ++ urg & 1 << i); ++ x += w; ++ } ++ w = TEXTW(m->ltsymbol); ++ drw_setscheme(drw, scheme[SchemeNorm]); ++ x = drw_text(drw, x, 0, w, bh + barheight, lrpad / 2, m->ltsymbol, 0); ++ ++ if ((w = barwidth - tw - x) > bh + barheight) { ++ if (m->sel) { ++ drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); ++ drw_text(drw, x, 0, w, bh + barheight, lrpad / 2, m->sel->name, 0); ++ if (m->sel->isfloating) ++ drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); ++ } else { ++ drw_setscheme(drw, scheme[SchemeNorm]); ++ drw_rect(drw, x, 0, w, bh + barheight, 1, 1); ++ } ++ } ++ drw_map(drw, m->barwin, 0, 0, barwidth, bh + barheight); + } + + void +@@ -1561,7 +1564,7 @@ setup(void) + if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) + die("no fonts could be loaded."); + lrpad = drw->fonts->h; +- bh = drw->fonts->h + 2; ++ bh = drw->fonts->h + 2 + barheight; + updategeom(); + /* init atoms */ + utf8string = XInternAtom(dpy, "UTF8_STRING", False); +@@ -1716,7 +1719,7 @@ togglebar(const Arg *arg) + { + selmon->showbar = !selmon->showbar; + updatebarpos(selmon); +- XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); ++ XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh + barheight); + arrange(selmon); + } + +@@ -1817,36 +1820,51 @@ unmapnotify(XEvent *e) + void + updatebars(void) + { +- Monitor *m; +- XSetWindowAttributes wa = { +- .override_redirect = True, +- .background_pixmap = ParentRelative, +- .event_mask = ButtonPressMask|ExposureMask +- }; +- XClassHint ch = {"dwm", "dwm"}; +- for (m = mons; m; m = m->next) { +- if (m->barwin) +- continue; +- m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen), +- CopyFromParent, DefaultVisual(dpy, screen), +- CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); +- XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); +- XMapRaised(dpy, m->barwin); +- XSetClassHint(dpy, m->barwin, &ch); +- } ++ Monitor *m; ++ XSetWindowAttributes wa = { ++ .override_redirect = True, ++ .background_pixmap = ParentRelative, ++ .event_mask = ButtonPressMask|ExposureMask ++ }; ++ XClassHint ch = {"dwm", "dwm"}; ++ for (m = mons; m; m = m->next) { ++ if (m->barwin) ++ continue; ++ if (floatbar) { ++ m->barwin = XCreateWindow(dpy, root, barpadh, barpadv, m->ww - 2 * barpadh, bh + barheight, 0, DefaultDepth(dpy, screen), ++ CopyFromParent, DefaultVisual(dpy, screen), ++ CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); ++ XSetWindowBorder(dpy, m->barwin, scheme[SchemeBar][ColBorder].pixel); ++ XSetWindowBorderWidth(dpy, m->barwin, barborder); ++ } else { ++ m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh + barheight, 0, DefaultDepth(dpy, screen), ++ CopyFromParent, DefaultVisual(dpy, screen), ++ CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); ++ } ++ XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); ++ XMapRaised(dpy, m->barwin); ++ XSetClassHint(dpy, m->barwin, &ch); ++ } + } + + void + updatebarpos(Monitor *m) + { +- m->wy = m->my; +- m->wh = m->mh; +- if (m->showbar) { +- m->wh -= bh; +- m->by = m->topbar ? m->wy : m->wy + m->wh; +- m->wy = m->topbar ? m->wy + bh : m->wy; +- } else +- m->by = -bh; ++ if (floatbar) { ++ /* IF YOU ARE USING GAPS, PLEASE ADD BARBORDER TO THE END */ ++ m->wy = m->my + (barheight + bh + barpadv * 2 + barborder); /* Start window area below the bar */ ++ m->wh = m->mh - (barheight + bh + barpadv * 2 + barborder); /* Reduce window height to account for bar */ ++ m->by = barpadv; /* Position bar at vertical padding from top */ ++ } else { ++ m->wy = m->my; ++ m->wh = m->mh; ++ if (m->showbar) { ++ m->wh -= bh + barheight; ++ m->by = m->topbar ? m->wy : m->wy + m->wh; ++ m->wy = m->topbar ? m->wy + bh : m->wy; ++ } else ++ m->by = -bh + barheight; ++ } + } + + void +-- +2.49.0 + diff --git a/dwm.suckless.org/patches/floatingstatus/index.md b/dwm.suckless.org/patches/floatingstatus/index.md @@ -0,0 +1,22 @@ +floatingstatus +============== + +Description +----------- +This is a patch that lets you transform the status bar into a floating bar. You can change the bar height and the vertical and horizontal padding. + +Config +------ +Everything is in config.h +* `barpadv` - [int] Vertical padding. How far from the top it is. +* `barpadh` - [int] Horizontal padding. How far from each side the bar is. +* `barheight` - [int] Height of the bar. How long the bar is vertically. +* `floatbar` - [Bool] Value to show / hide the bar + +Download +-------- +* [floatingstatus-20250408-cfb8627.diff](floatingstatus-20250408-cfb8627.diff) - Latest + +Authors +------- +* Abhinav Prasai - <abhinav.prsai@gmail.com> diff --git a/dwm.suckless.org/patches/floatingstatus/screenshot.png b/dwm.suckless.org/patches/floatingstatus/screenshot.png Binary files differ.