sites

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

commit ed95f7dc844ed633a531c69562fcade6c86aa30b
parent 31265cd6b3bd1e5a075f837848f7285c09162659
Author: Daniel Guihot <daniel@guihot.net>
Date:   Sun,  5 Jul 2026 03:48:14 +1000

Patch for a floating dmenu bar with padding/height/border (extension of floatingstatus for dwm)

Diffstat:
Atools.suckless.org/dmenu/patches/floatingbar/bar.png | 0
Atools.suckless.org/dmenu/patches/floatingbar/dmenu-floatingbar-5.4.diff | 110+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atools.suckless.org/dmenu/patches/floatingbar/dmenu.png | 0
Atools.suckless.org/dmenu/patches/floatingbar/index.md | 34++++++++++++++++++++++++++++++++++
4 files changed, 144 insertions(+), 0 deletions(-)

diff --git a/tools.suckless.org/dmenu/patches/floatingbar/bar.png b/tools.suckless.org/dmenu/patches/floatingbar/bar.png Binary files differ. diff --git a/tools.suckless.org/dmenu/patches/floatingbar/dmenu-floatingbar-5.4.diff b/tools.suckless.org/dmenu/patches/floatingbar/dmenu-floatingbar-5.4.diff @@ -0,0 +1,110 @@ +From: Daniel Guihot <daniel@guihot.net> +Subject: [dmenu][patch] floatingmenu v1.0 - floating dmenu bar with padding/height/border (extension of floatingstatus for dwm) + +NOTE: Added extra flag, '-bo', which allows you to specify the colour of the border explicitly. +By default, the background just inherits the '-sb' flag, to cooperate with default dwm behaviour. + +This is my first time patching suckless software. Please feel free to email me if you encounter any issues. + +See also: https://dwm.suckless.org/patches/floatingstatus/ + +diff --git a/config.def.h b/config.def.h +--- a/config.def.h ++++ b/config.def.h +@@ -2,6 +2,12 @@ + /* Default settings; can be overriden by command line. */ + + static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ ++ ++static unsigned int barpadh = 200; ++static unsigned int barpadv = 10; ++static unsigned int barheight = 2; ++static unsigned int barborder = 2; ++ + /* -fn option overrides fonts[0]; default X11 font or font set */ + static const char *fonts[] = { + "monospace:size=10" +@@ -12,6 +18,7 @@ + [SchemeNorm] = { "#bbbbbb", "#222222" }, + [SchemeSel] = { "#eeeeee", "#005577" }, + [SchemeOut] = { "#000000", "#00ffff" }, ++ [SchemeBorder] = { "#005577", "#005577" }, + }; + /* -l option; if nonzero, dmenu uses vertical list with given number of lines */ + static unsigned int lines = 0; +diff --git a/dmenu.c b/dmenu.c +--- a/dmenu.c ++++ b/dmenu.c +@@ -25,7 +25,7 @@ + #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) + + /* enums */ +-enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */ ++enum { SchemeNorm, SchemeSel, SchemeOut, SchemeBorder, SchemeLast }; /* color schemes */ + + struct item { + char *text; +@@ -633,7 +633,7 @@ + utf8 = XInternAtom(dpy, "UTF8_STRING", False); + + /* calculate menu geometry */ +- bh = drw->fonts->h + 2; ++ bh = drw->fonts->h + 2 + 2 * barheight; + lines = MAX(lines, 0); + mh = (lines + 1) * bh; + #ifdef XINERAMA +@@ -662,9 +662,9 @@ + if (INTERSECT(x, y, 1, 1, info[i]) != 0) + break; + +- x = info[i].x_org; +- y = info[i].y_org + (topbar ? 0 : info[i].height - mh); +- mw = info[i].width; ++ x = info[i].x_org + barpadh; ++ y = info[i].y_org + (topbar ? barpadv : info[i].height - mh - barpadv); ++ mw = info[i].width - 2 * barpadh; + XFree(info); + } else + #endif +@@ -672,9 +672,9 @@ + if (!XGetWindowAttributes(dpy, parentwin, &wa)) + die("could not get embedding window attributes: 0x%lx", + parentwin); +- x = 0; +- y = topbar ? 0 : wa.height - mh; +- mw = wa.width; ++ x = barpadh; ++ y = topbar ? barpadv : wa.height - mh - barpadv; ++ mw = wa.width - 2 * barpadh; + } + promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0; + inputw = mw / 3; /* input width: ~33% of monitor width */ +@@ -684,9 +684,11 @@ + swa.override_redirect = True; + swa.background_pixel = scheme[SchemeNorm][ColBg].pixel; + swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask; +- win = XCreateWindow(dpy, root, x, y, mw, mh, 0, ++ win = XCreateWindow(dpy, root, x, y, mw, mh, barborder, + CopyFromParent, CopyFromParent, CopyFromParent, + CWOverrideRedirect | CWBackPixel | CWEventMask, &swa); ++ if (barborder) ++ XSetWindowBorder(dpy, win, scheme[SchemeBorder][ColFg].pixel); + XSetClassHint(dpy, win, &ch); + + /* input methods */ +@@ -751,10 +753,14 @@ + colors[SchemeNorm][ColBg] = argv[++i]; + else if (!strcmp(argv[i], "-nf")) /* normal foreground color */ + colors[SchemeNorm][ColFg] = argv[++i]; +- else if (!strcmp(argv[i], "-sb")) /* selected background color */ ++ else if (!strcmp(argv[i], "-sb")) { /* selected background color */ + colors[SchemeSel][ColBg] = argv[++i]; ++ colors[SchemeSel][ColFg] = colors[SchemeSel][ColBg]; ++ } + else if (!strcmp(argv[i], "-sf")) /* selected foreground color */ + colors[SchemeSel][ColFg] = argv[++i]; ++ else if (!strcmp(argv[i], "-bo")) /* border colour */ ++ colors[SchemeBorder][ColFg] = argv[++i]; + else if (!strcmp(argv[i], "-ob")) /* outline background color */ + colors[SchemeOut][ColBg] = argv[++i]; + else if (!strcmp(argv[i], "-of")) /* outline foreground color */ diff --git a/tools.suckless.org/dmenu/patches/floatingbar/dmenu.png b/tools.suckless.org/dmenu/patches/floatingbar/dmenu.png Binary files differ. diff --git a/tools.suckless.org/dmenu/patches/floatingbar/index.md b/tools.suckless.org/dmenu/patches/floatingbar/index.md @@ -0,0 +1,34 @@ +# Description +This patch allows you to transform the dmenu into a floating bar, with customizable height, as well as vertical and horizontal padding. This is an extension of [floatingstatus](https://dwm.suckless.org/patches/floatingstatus/) for dwm. + +NOTE: Added an extra flag, '-bo', which allows you to specify the colour of the border explicitly. +By default, the background just inherits the '-sb' flag, to cooperate with default dwm behaviour. + +This is my first time patching suckless software. Please feel free to email me if you encounter any issues. + +See also: https://dwm.suckless.org/patches/floatingstatus/ + +<div style="text-align: center;"> + <img src="bar.png" alt="dwm bar" width="1200"> +</div> + +<div style="text-align: center;"> + <img src="dmenu.png" alt="dmenu with patch" width="1200"> +</div> + +## Config + +Everything is in ``config.def.h`` + + barpadh - [int] Vertical padding: how far the bar is from the top. + barpadv - [int] Horizontal padding: how far the bar is from each side. + barheight - [int] Bar height: How long the bar is vertically. + barborder - [int] Bar border: How thick the border is. + +## Download + +[dmenu-floatingbar-5.4.diff](https://github.com/danskullz/dmenu-floatingbar/raw/refs/heads/main/dmenu-floatingbar-5.4.diff) + +## Authors + + Daniel Guihot - daniel@guihot.net