diff options
| author | auric <104602845+ihateamongus@users.noreply.github.com> | 2025-09-11 10:47:54 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-11 10:47:54 -0500 |
| commit | 9ece199b4aec527f511016f5f7c7b578b52eb912 (patch) | |
| tree | 7ffb7e055305a03c0971855a5396dc242907aba0 | |
| parent | 089761fb4a6216ba64acbe52c0b72d87a1d9e0ae (diff) | |
| parent | 57b25f6e023ff36ed7329637d066c4b38953dbcc (diff) | |
Merge pull request #27 from ihateamongus/codex/create-universal-launcher-with-dmenu
Tweaks
| -rw-r--r-- | core/dmenu/dmenu.c | 24 | ||||
| -rw-r--r-- | core/dwm/config.def.h | 4 | ||||
| -rw-r--r-- | core/dwm/config.h | 5 | ||||
| -rw-r--r-- | tools/universal_launcher.txt | 2 |
4 files changed, 25 insertions, 10 deletions
diff --git a/core/dmenu/dmenu.c b/core/dmenu/dmenu.c index b009179..6ca6db6 100644 --- a/core/dmenu/dmenu.c +++ b/core/dmenu/dmenu.c @@ -41,6 +41,7 @@ struct item { static char text[BUFSIZ] = ""; static char *embed; static int bh, mw, mh; +static int ih; static int promptw; static int lrpad; /* sum of left and right padding */ static size_t cursor; @@ -169,26 +170,30 @@ drawmenu(void) if (prompt && *prompt) { drw_setscheme(drw, scheme[SchemeSel]); - x = drw_text(drw, x, 0, promptw, bh, lrpad / 2, prompt, 0); + x = drw_text(drw, x, 0, promptw, ih, lrpad / 2, prompt, 0); } /* draw input field */ w = mw - x; drw_setscheme(drw, scheme[SchemeNorm]); - drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0); + drw_text(drw, x, 0, w, ih, lrpad / 2, text, 0); curpos = TEXTW(text) - TEXTW(&text[cursor]); if ((curpos += lrpad / 2 - 1) < w) { + int cy = (ih - bh) / 2 + 2; drw_setscheme(drw, scheme[SchemeNorm]); - drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0); + drw_rect(drw, x + curpos, cy, 2, bh - 4, 1, 0); } + drw_setscheme(drw, accent); + drw_rect(drw, 0, ih - 1, mw, 1, 1, 1); + + y = ih; for (item = curr; item != next; item = item->right) { - y += bh; drawitem(item, x, y, mw - x); drw_setscheme(drw, accent); drw_rect(drw, x, y + bh - 1, mw - x, 1, 1, 1); + y += bh; } - drw_map(drw, win, 0, 0, mw, mh); } @@ -637,6 +642,7 @@ setup(void) /* calculate menu geometry */ bh = drw->fonts->h + 2; + ih = (bh * 3) / 2; #ifdef XINERAMA i = 0; if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) { @@ -661,9 +667,9 @@ setup(void) break; mw = info[i].width / 2; - int max_lines = info[i].height / bh - 1; + int max_lines = (info[i].height - ih) / bh; lines = lines ? MIN(lines, max_lines) : MIN(20, max_lines); - mh = (lines + 1) * bh; + mh = ih + lines * bh; x = info[i].x_org + (info[i].width - mw) / 2; y = info[i].y_org + (info[i].height - mh) / 2; XFree(info); @@ -674,9 +680,9 @@ setup(void) die("could not get embedding window attributes: 0x%lx", parentwin); mw = wa.width / 2; - int max_lines = wa.height / bh - 1; + int max_lines = (wa.height - ih) / bh; lines = lines ? MIN(lines, max_lines) : MIN(20, max_lines); - mh = (lines + 1) * bh; + mh = ih + lines * bh; x = (wa.width - mw) / 2; y = (wa.height - mh) / 2; } diff --git a/core/dwm/config.def.h b/core/dwm/config.def.h index c94f430..394937d 100644 --- a/core/dwm/config.def.h +++ b/core/dwm/config.def.h @@ -71,6 +71,8 @@ static const char *screenshotcmd[] = { "flameshot", "gui", NULL }; static const char *mediaplaypause[] = { "playerctl", "play-pause", NULL }; static const char *medianext[] = { "playerctl", "next", NULL }; static const char *mediaprev[] = { "playerctl", "previous", NULL }; +static const char *powermenucmd[] = { "/bin/sh", "-c", "power-menu.sh", NULL }; +static const char *steamcmd[] = { "/bin/sh", "-c", "steam-dmenu.sh", NULL }; static const Key keys[] = { /* modifier key function argument */ @@ -79,6 +81,8 @@ static const Key keys[] = { { MODKEY, XK_F1, spawn, {.v = browsercmd } }, { 0, XK_Print, spawn, {.v = screenshotcmd } }, { MODKEY, XK_grave, togglescratch, {.v = scratchpadcmd } }, + { MODKEY|ShiftMask, XK_p, spawn, {.v = powermenucmd } }, + { MODKEY|ControlMask, XK_p, spawn, {.v = steamcmd } }, { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, diff --git a/core/dwm/config.h b/core/dwm/config.h index c89c80d..9525e86 100644 --- a/core/dwm/config.h +++ b/core/dwm/config.h @@ -73,7 +73,8 @@ static const char *medianext[] = { "playerctl", "next", NULL }; static const char *mediaprev[] = { "playerctl", "previous", NULL }; static const char *calendarcmd[] = { "/bin/sh", "-c", "st -e sh -c 'cal -3 | less'", NULL }; static const char *dunstlogcmd[] = { "/bin/sh", "-c", "st -e sh -c 'less -+F \"$HOME/.cache/dunst/dunst.log\"'", NULL }; -static const char *powermenucmd[] = { "/bin/sh", "-c", "printf '%s\n' lock reboot shutdown | dmenu | xargs -r -I{} sh -c 'case \"{}\" in lock) slock ;; reboot) loginctl reboot ;; shutdown) loginctl poweroff ;; esac'", NULL }; +static const char *powermenucmd[] = { "/bin/sh", "-c", "power-menu.sh", NULL }; +static const char *steamcmd[] = { "/bin/sh", "-c", "steam-dmenu.sh", NULL }; static const Key keys[] = { /* modifier key function argument */ @@ -82,6 +83,8 @@ static const Key keys[] = { { MODKEY, XK_F1, spawn, {.v = browsercmd } }, { 0, XK_Print, spawn, {.v = screenshotcmd } }, { MODKEY, XK_grave, togglescratch, {.v = scratchpadcmd } }, + { MODKEY|ShiftMask, XK_p, spawn, {.v = powermenucmd } }, + { MODKEY|ControlMask, XK_p, spawn, {.v = steamcmd } }, { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, diff --git a/tools/universal_launcher.txt b/tools/universal_launcher.txt index ef46ae0..8bfd9a4 100644 --- a/tools/universal_launcher.txt +++ b/tools/universal_launcher.txt @@ -3,3 +3,5 @@ Universal launcher notes: - Added `steam-dmenu.sh` to list installed Steam games and launch them. - Added `power-menu.sh` for locking, rebooting, and shutting down. - Patched dmenu to center on screen, size dynamically, draw a 3px accent-colored border and separators, and update colors from accent.h. +- Enlarged dmenu's input field and added an accent divider beneath it. +- Added dwm keybindings: `Mod+Shift+p` for the power menu and `Mod+Ctrl+p` for the Steam launcher. |
