commit 1b614cbf5498dbe5858bab78edf0fc09c66f7feb
Author: mrfox <jens.se@icloud.com>
AuthorDate: Sun Sep 20 21:32:35 2026 +0200
Commit: mrfox <jens.se@icloud.com>
CommitDate: Sun Sep 20 21:32:35 2026 +0200
dmenu: build from source with the suckless center patch
The old MrJensK/dmenu fork this used to build from is gone (404 on
GitHub, never existed on the self-hosted server either), so dmenu was
silently falling back to the unpatched apt package with no centered
box -- lost, seemingly by accident, when SXBAR_REPO moved to the
self-hosted server in c6ab0aa.
Rebuilt the same behavior on vanilla upstream dmenu instead of a
personal fork: clone git.suckless.org/dmenu and apply the standard
suckless "center" patch (dmenu-patches/01-center.patch, adds -c). The
vertical list doesn't need a patch -- stock dmenu already supports
"-l lines" -- so sxwmrc's mod+p bind is just "dmenu_run -c -l 10".
Verified by building the patched dmenu and rendering it: centers
correctly on screen and lists candidates vertically.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
---
README.md | 19 ++++++--
config/sxwmrc | 2 +-
dmenu-patches/01-center.patch | 104 ++++++++++++++++++++++++++++++++++++++++++
install.sh | 21 ++++++++-
4 files changed, 141 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 9f97ff2..3d99780 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,7 @@
- [Installation](#installation)
- [Structure](#structure)
- [sxwm patches](#sxwm-patches)
+- [dmenu patches](#dmenu-patches)
- [st patches](#st-patches)
- [st quirks](#st-quirks)
- [Keyboard shortcuts (sxwm)](#keyboard-shortcuts-sxwm)
@@ -49,7 +50,8 @@ This is my personal dotfiles setup for a lightweight, keyboard-driven X11 deskto
environment built around [`sxwm`](https://github.com/uint23/sxwm) (tiling window
manager, patched with a handful of local fixes — see [below](#sxwm-patches)),
[`sxbar`](https://github.com/MrJensK/sxbar) (status bar),
-[`dmenu`](https://github.com/MrJensK/dmenu) (application launcher) and
+[`dmenu`](https://tools.suckless.org/dmenu/) (application launcher, patched to
+appear centered — see [below](#dmenu-patches)) and
[`st`](https://st.suckless.org/) (terminal, patched with a curated set of
upstream suckless patches — see [below](#st-patches)). Everything is set up
automatically via [`install.sh`](install.sh) — clone the repo, run the script,
@@ -61,7 +63,7 @@ and you have a working environment.
|---|---|
| 🪟 | **sxwm** — tiling window manager, patched with 5 local fixes (DPI, taskbar focus, multi-monitor struts, hotplug remap, fullscreen targeting) |
| 📊 | **sxbar** — status bar with clock, date, battery, volume, CPU, brightness, Bluetooth, network, media player, taskbar and start menu popups |
-| 🚀 | **dmenu** — fast application launcher (`mod + p`) |
+| 🚀 | **dmenu** — fast application launcher (`mod + p`), centered on screen with results listed vertically |
| 📶 | **bluetui** — Bluetooth management right in the terminal |
| 🖥️ | **st** — suckless terminal, patched with 11 upstream fixes (scrollback, clipboard, box-drawing, alpha, blinking cursor, inline images, and more) |
| 🔤 | **JetBrainsMono Nerd Font** — icon support in the bar and terminal |
@@ -148,6 +150,8 @@ dotfiles/
│ ├── screensaver.txt # ASCII art shown by the screensaver
│ └── status # Overview: WM stack, services, network, bluetooth, audio, battery, lock state
├── *.patch # Local sxwm patches, see "sxwm patches" below
+├── dmenu-patches/ # Upstream dmenu patches, see "dmenu patches" below
+│ └── 01-center.patch
├── st-patches/ # Upstream st patches, see "st patches" below
│ ├── 01-delkey.patch
│ ├── 02-scrollback.patch
@@ -195,6 +199,15 @@ order:
| [`fullscreen-monitor-fix.patch`](fullscreen-monitor-fix.patch) | Fullscreening a window that had been moved to another monitor by an external tool (`xdotool`, `screensaver-launch`) fullscreened it on the wrong screen; the target monitor is now recomputed from the window's real geometry |
| [`strut-fresh-screen-size.patch`](strut-fresh-screen-size.patch) | A bottom/right-edge panel (e.g. sxbar's `secondary_bar`) could end up hidden behind normal windows — `reserve_bottom`/`reserve_right` are measured from the *opposite* screen edge and need the full screen size, but read it from `scr_width`/`scr_height`, cached globals only refreshed by `update_mons()`; `reserve_top`/`reserve_left` never depend on screen size so stayed correct. Reads the screen size fresh from the X server instead |
+## dmenu patches
+
+`install.sh` clones upstream `dmenu` (from suckless.org, not a distro package)
+and applies this on top before building:
+
+| Patch | Adds |
+|---|---|
+| [`01-center.patch`](dmenu-patches/01-center.patch) | The standard [suckless "center" patch](https://tools.suckless.org/dmenu/patches/center/): a `-c` flag that opens dmenu as a centered box instead of a full-width bar. `sxwmrc`'s `mod + p` bind passes `-c -l 10` — the vertical list (`-l lines`) is stock dmenu, no patch needed for that part |
+
## st patches
`install.sh` clones upstream `st` (v0.9.3) and applies these on top before
@@ -293,7 +306,7 @@ worth writing down:
|---|---|
| `mod + Return` | Open st |
| `mod + b` | Open Firefox |
-| `mod + p` | dmenu (application launcher) |
+| `mod + p` | dmenu (application launcher, centered, 10-line vertical list) |
| `mod + q` | Close window |
| `mod + shift + e` | Quit sxwm |
| `mod + c` | Centre window |
diff --git a/config/sxwmrc b/config/sxwmrc
index 5520a2b..ec94c76 100644
--- a/config/sxwmrc
+++ b/config/sxwmrc
@@ -37,7 +37,7 @@ mod_key : super
# Application Launchers:
bind : mod + Return : "st"
bind : mod + b : "firefox"
-bind : mod + p : "dmenu_run"
+bind : mod + p : "dmenu_run -c -l 10"
bind : mod + shift + s : "screensaver-toggle"
# Window Management:
diff --git a/dmenu-patches/01-center.patch b/dmenu-patches/01-center.patch
new file mode 100644
index 0000000..9401dc5
--- /dev/null
+++ b/dmenu-patches/01-center.patch
@@ -0,0 +1,104 @@
+diff --git a/config.def.h b/config.def.h
+index 1edb647..88ef264 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -2,6 +2,8 @@
+ /* Default settings; can be overriden by command line. */
+
+ static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
++static int centered = 0; /* -c option; centers dmenu on screen */
++static int min_width = 500; /* minimum width when centered */
+ /* -fn option overrides fonts[0]; default X11 font or font set */
+ static const char *fonts[] = {
+ "monospace:size=10"
+diff --git a/dmenu.1 b/dmenu.1
+index 323f93c..c036baa 100644
+--- a/dmenu.1
++++ b/dmenu.1
+@@ -40,6 +40,9 @@ which lists programs in the user's $PATH and runs the result in their $SHELL.
+ .B \-b
+ dmenu appears at the bottom of the screen.
+ .TP
++.B \-c
++dmenu appears centered on the screen.
++.TP
+ .B \-f
+ dmenu grabs the keyboard before reading stdin if not reading from a tty. This
+ is faster, but will lock up X until stdin reaches end\-of\-file.
+diff --git a/dmenu.c b/dmenu.c
+index 27b7a30..427fb04 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -96,6 +96,15 @@ calcoffsets(void)
+ break;
+ }
+
++static int
++max_textw(void)
++{
++ int len = 0;
++ for (struct item *item = items; item && item->text; item++)
++ len = MAX(TEXTW(item->text), len);
++ return len;
++}
++
+ static void
+ cleanup(void)
+ {
+@@ -636,6 +645,7 @@ setup(void)
+ bh = drw->fonts->h + 2;
+ lines = MAX(lines, 0);
+ mh = (lines + 1) * bh;
++ promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
+ #ifdef XINERAMA
+ i = 0;
+ if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
+@@ -662,9 +672,16 @@ setup(void)
+ 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;
++ if (centered) {
++ mw = MIN(MAX(max_textw() + promptw, min_width), info[i].width);
++ x = info[i].x_org + ((info[i].width - mw) / 2);
++ y = info[i].y_org + ((info[i].height - mh) / 2);
++ } else {
++ x = info[i].x_org;
++ y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
++ mw = info[i].width;
++ }
++
+ XFree(info);
+ } else
+ #endif
+@@ -672,9 +689,16 @@ setup(void)
+ 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;
++
++ if (centered) {
++ mw = MIN(MAX(max_textw() + promptw, min_width), wa.width);
++ x = (wa.width - mw) / 2;
++ y = (wa.height - mh) / 2;
++ } else {
++ x = 0;
++ y = topbar ? 0 : wa.height - mh;
++ mw = wa.width;
++ }
+ }
+ promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
+ inputw = mw / 3; /* input width: ~33% of monitor width */
+@@ -733,6 +757,8 @@ main(int argc, char *argv[])
+ topbar = 0;
+ else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
+ fast = 1;
++ else if (!strcmp(argv[i], "-c")) /* centers dmenu on screen */
++ centered = 1;
+ else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
+ fstrncmp = strncasecmp;
+ fstrstr = cistrstr;
diff --git a/install.sh b/install.sh
index 0557e40..cceb5e2 100755
--- a/install.sh
+++ b/install.sh
@@ -11,6 +11,7 @@ set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SXWM_REPO="https://github.com/uint23/sxwm.git"
SXBAR_REPO="https://git.kristoffersson.info/repos/sxbar.git"
+DMENU_REPO="https://git.suckless.org/dmenu"
ST_REPO="https://git.suckless.org/st"
BUILD_DIR="/tmp/sxwm-sxbar-build"
LOG_FILE="/tmp/dotfiles-install.log"
@@ -423,7 +424,6 @@ step_deps() {
x11-utils \
pipx \
feh \
- dmenu \
imagemagick \
bc \
geany \
@@ -486,6 +486,24 @@ step_sxbar() {
sudo make install
}
+step_dmenu() {
+ mkdir -p "$BUILD_DIR"
+ cd "$BUILD_DIR"
+ rm -rf dmenu
+ git clone --depth=1 "$DMENU_REPO" dmenu
+
+ # center: adds the -c flag (centers dmenu on screen instead of the default
+ # full-width top bar). Combined with -l in sxwmrc's dmenu_run bind for the
+ # vertical list -- that part is stock dmenu (-l lines), no patch needed.
+ cd dmenu
+ for p in "$SCRIPT_DIR"/dmenu-patches/*.patch; do
+ patch -p1 < "$p"
+ done
+
+ make
+ sudo make install
+}
+
step_st() {
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
@@ -931,6 +949,7 @@ fi
add_step 10 "Installerar beroenden" step_deps
add_step 3 "Bygger sxwm" step_sxwm
add_step 2 "Bygger sxbar" step_sxbar
+add_step 1 "Bygger dmenu" step_dmenu
add_step 4 "Bygger st" step_st
add_step 1 "Kopierar konfigfiler" step_configs
add_step 1 "Installerar Geany & Gruvbox" step_theme