No description
- C 96.6%
- Makefile 3.4%
| .gitignore | ||
| config.h | ||
| dwm-grid.c | ||
| Makefile | ||
| README | ||
dwm-grid — standalone workspace-grid overlay for dwm
====================================================
A small Xlib app (dmenu-style) that pops up a centered grid of all dwm
workspaces (tags), highlights the currently-viewed one, shades occupied
ones, and lists the window titles inside each cell.
It is completely decoupled from dwm: it holds no shared state and links
against no dwm code. Everything it draws is read from X-server window
properties that dwm publishes, and it redraws live via PropertyNotify.
It does NOT grab the keyboard. It passively grabs only its own quit keys
(Escape and q) via XGrabKey, so dwm keeps full keyboard control while the
grid is open — you can switch/move workspaces (MODKEY+1..9, etc.) and watch
the grid update live. Dismiss with Escape, q, or MODKEY+S.
Single instance / toggle: the running instance records its window id in the
root property _DWM_GRID_WIN. A second launch (i.e. pressing MODKEY+S again,
which dwm binds to `spawn dwm-grid`) detects it, sends it a _DWM_GRID_QUIT
ClientMessage, and exits — so MODKEY+S toggles the overlay and it never
starts twice. A stale id from a crashed instance is detected and ignored.
Requires the grid-aware dwm (the one that exports the _DWM_* atoms).
Properties consumed
-------------------
Root window (view/shape state):
_DWM_GRID CARDINAL[3] ntags, cols, rows (dwm owns the shape)
_DWM_CELLS CARDINAL[2n] explicit (col,row) per tag: c0,r0,c1,r1,...
_DWM_TAG_NAMES UTF8_STRING NUL-separated tag labels
_DWM_NMONS CARDINAL monitor count
_DWM_SELMON CARDINAL focused monitor index
_DWM_SELTAGS CARDINAL[n] per-monitor viewed-tag bitmask
_DWM_OCCTAGS CARDINAL[n] per-monitor occupied-tag bitmask
_NET_CLIENT_LIST WINDOW[] all managed windows
Per client window (which cell a window belongs to):
_DWM_WM_TAGS CARDINAL tag bitmask (bit i => tags[i])
_NET_WM_NAME UTF8_STRING title (falls back to WM_NAME)
The grid shows the focused monitor (_DWM_SELMON). Each tag's cell is given
explicitly by _DWM_CELLS (dwm owns the placement, defined by hand in its
config.h gridcell[]), so rows can have different widths and cells may be
left empty. If _DWM_CELLS is absent the viewer falls back to row-major
placement (col = i % cols, row = i / cols).
Build & run
-----------
make
./dwm-grid
make install # installs to /usr/local/bin (override PREFIX=)
dwm binds it to MODKEY+S in config.h (already added):
static const char *gridcmd[] = { "dwm-grid", NULL };
{ MODKEY, XK_s, spawn, {.v = gridcmd } },
Pressing MODKEY+S again toggles it off (see "Single instance / toggle").
The binary must be on PATH (e.g. installed to ~/.local/bin or via `make
install` to /usr/local/bin) so dwm can spawn it.
Configuration
-------------
Edit config.h (font, gruvbox colors, cell width, padding, maxtitles) and
rebuild. Cell *height* is derived from the font metrics so the label plus
`maxtitles` window titles always fit at any DPI. If a cell holds more
windows than maxtitles, the last line shows "+N more".