birdwm

birdwm - mrgrouse's daily driver fork of suckless' dwm. Contains many patches and is currently loosely maintained.
Log | Files | Refs | README | LICENSE

commit 000e1967d77a9c7b0e5b96cb2d5a55d9451b7064
parent a9635df43709f88e4c6f54a3f69f4bd452b01719
Author: mrgrouse <bdmfegys@duck.com>
Date:   Thu,  3 Jul 2025 05:33:39 -0400

patch scratchpads, and add in our scripts and keybinds from birdwm

Diffstat:
Mconfig.def.h | 62++++++++++++++++++++++++++++++++++++++++++++++++++++----------
Mconfig.mk | 10+++++++---
Mdwm.c | 43+++++++++++++++++++++++++++++++++++++++++--
3 files changed, 100 insertions(+), 15 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -1,5 +1,5 @@ /* See LICENSE file for copyright and license details. */ - +#include <X11/XF86keysym.h> /* appearance */ static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int gappx = 6; /* gaps between windows */ @@ -11,8 +11,8 @@ static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display static const int showsystray = 1; /* 0 means no systray */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ -static const char *fonts[] = { "monospace:size=10" }; -static const char dmenufont[] = "monospace:size=10"; +static const char *fonts[] = { "LexendDeca-Bold:pixelsize=18" }; +static const unsigned int altmonnum = 1; /* my personal second monitor for remembering which window rules go in which tag and which monitor */ static const char col_gray1[] = "#222222"; static const char col_gray2[] = "#444444"; static const char col_gray3[] = "#bbbbbb"; @@ -24,6 +24,23 @@ static const char *colors[][3] = { [SchemeSel] = { col_gray4, col_cyan, col_cyan }, }; +typedef struct { + const char *name; + const void *cmd; +} Sp; +const char *spcmd1[] = {"birdterm", "-n", "spterm", "-g", "144x41", NULL }; +const char *spcmd2[] = {"birdterm", "-n", "spfm", "-g", "144x41", "-e", "nnn -Pp", NULL }; +const char *spcmd3[] = {"birdterm", "-n", "upgrader", "-g", "144x41", "-e", "upgrader.sh", NULL }; +const char *spcmd4[] = {"birdterm", "-n", "spmpc", "-g", "144x41", "-e", "rmpc", NULL }; +static Sp scratchpads[] = { + /* name cmd */ + {"spterm", spcmd1}, + {"spranger", spcmd2}, + {"upgrader", spcmd3}, + {"spmpc", spcmd4}, +}; + + /* tagging */ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; @@ -32,9 +49,16 @@ static const Rule rules[] = { * WM_CLASS(STRING) = instance, class * WM_NAME(STRING) = title */ - /* class instance title tags mask iscentered isfloating monitor */ - { "Gimp", NULL, NULL, 0, 0, 1, -1 }, - { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1 }, + /* class instance title tags mask iscentered isfloating monitor */ + { "Gimp", NULL, NULL, 0, 1, 1, -1 }, + { "Firefox", NULL, NULL, 1 << 8, 0, 1, -1 }, + { NULL, "spterm", NULL, SPTAG(0), 1, 1, -1 }, + { NULL, "spfm", NULL, SPTAG(1), 1, 1, -1 }, + { NULL, "upgrader", NULL, SPTAG(3), 1, 1, -1 }, + { NULL, "spmpc", NULL, SPTAG(4), 1, 1, -1 }, + { "vesktop", "vesktop", NULL, 1 << 4, 0, 0, altmonnum }, /* starts vesktop discord client on the discord icon tag */ + { "tutanota-desktop","tutanota-desktop",NULL,1 << 5,0, 0, altmonnum }, /* starts tutanota-desktop on the mail tag */ + { "Signal", "signal", NULL, 1 << 2, 0, 0, altmonnum }, /* starts element on the chat tag */ }; /* layout(s) */ @@ -63,13 +87,28 @@ static const Layout layouts[] = { /* commands */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ -static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; -static const char *termcmd[] = { "st", NULL }; +static const char *dmenucmd[] = { "birdmenu_run", "-i", NULL }; +static const char *termcmd[] = { "birdmenu", NULL }; +static const char *wallpaper[] = { "nsxiv", "-t", WALLPAPERDIR, NULL }; +static const char *browser[] = { "net.mullvad.MullvadBrowser", NULL }; +static const char *passman[] = { "kpmenu", NULL}; +static const char *emojiscript[] = { "dmenu-emoji.sh", NULL }; + +static const char *volup[] = { "volume.sh", "up", NULL }; +static const char *voldown[] = { "volume.sh", "down", NULL }; +static const char *volmute[] = { "volume.sh", "mute", NULL }; static const Key keys[] = { /* modifier key function argument */ { MODKEY, XK_p, spawn, {.v = dmenucmd } }, { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, + { MODKEY, XK_w, spawn, {.v = wallpaper } }, + { MODKEY, XK_k, spawn, {.v = passman } }, + { MODKEY, XK_e, spawn, {.v = emojiscript } }, + { MODKEY, XK_f, spawn, {.v = browser } }, + { 0, XF86XK_AudioRaiseVolume, spawn, {.v = volup } }, + { 0, XF86XK_AudioLowerVolume, spawn, {.v = voldown } }, + { 0, XF86XK_AudioMute, spawn, {.v = volmute } }, { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, @@ -81,7 +120,7 @@ static const Key keys[] = { { MODKEY, XK_Tab, view, {0} }, { MODKEY|ShiftMask, XK_c, killclient, {0} }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, - { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, + { MODKEY|ShiftMask, XK_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, @@ -91,6 +130,9 @@ static const Key keys[] = { { MODKEY, XK_period, focusmon, {.i = +1 } }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, + { MODKEY, XK_y, togglescratch, {.ui = 0 } }, + { MODKEY, XK_u, togglescratch, {.ui = 1 } }, + { MODKEY, XK_x, togglescratch, {.ui = 2 } }, TAGKEYS( XK_1, 0) TAGKEYS( XK_2, 1) TAGKEYS( XK_3, 2) @@ -113,7 +155,7 @@ static const Button buttons[] = { { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, { ClkClientWin, MODKEY, Button1, movemouse, {0} }, { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, - { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, + { ClkClientWin, MODKEY, Button1, resizemouse, {0} }, { ClkTagBar, 0, Button1, view, {0} }, { ClkTagBar, 0, Button3, toggleview, {0} }, { ClkTagBar, MODKEY, Button1, tag, {0} }, diff --git a/config.mk b/config.mk @@ -14,6 +14,10 @@ X11LIB = /usr/X11R6/lib XINERAMALIBS = -lXinerama XINERAMAFLAGS = -DXINERAMA +# Wallpaper folder location, for the wallpaper script: +XDG_PICTURES ?= ${HOME}/Pictures +WALLPAPERDIR = ${XDG_PICTURES}/wallpapers + # freetype FREETYPELIBS = -lfontconfig -lXft FREETYPEINC = /usr/include/freetype2 @@ -26,9 +30,9 @@ INCS = -I${X11INC} -I${FREETYPEINC} LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} # flags -CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} +CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} -DWALLPAPERDIR=\"${WALLPAPERDIR}\" #CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS} -CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS} +CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -O3 -march=native ${INCS} ${CPPFLAGS} LDFLAGS = ${LIBS} # Solaris @@ -36,4 +40,4 @@ LDFLAGS = ${LIBS} #LDFLAGS = ${LIBS} # compiler and linker -CC = cc +CC = gcc diff --git a/dwm.c b/dwm.c @@ -53,7 +53,10 @@ #define MOUSEMASK (BUTTONMASK|PointerMotionMask) #define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx) #define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx) -#define TAGMASK ((1 << LENGTH(tags)) - 1) +#define NUMTAGS (LENGTH(tags) + LENGTH(scratchpads)) +#define TAGMASK ((1 << NUMTAGS) - 1) +#define SPTAG(i) ((1 << LENGTH(tags)) << (i)) +#define SPTAGMASK (((1 << LENGTH(scratchpads))-1) << LENGTH(tags)) #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) #define SYSTEM_TRAY_REQUEST_DOCK 0 @@ -237,6 +240,7 @@ static void tagmon(const Arg *arg); static void tile(Monitor *m); static void togglebar(const Arg *arg); static void togglefloating(const Arg *arg); +static void togglescratch(const Arg *arg); static void toggletag(const Arg *arg); static void toggleview(const Arg *arg); static void unfocus(Client *c, int setfocus); @@ -333,6 +337,11 @@ applyrules(Client *c) c->iscentered = r->iscentered; c->isfloating = r->isfloating; c->tags |= r->tags; + if ((r->tags & SPTAGMASK) && r->isfloating) { + c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2); + c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2); + } + for (m = mons; m && m->num != r->monitor; m = m->next); if (m) c->mon = m; @@ -342,7 +351,7 @@ applyrules(Client *c) XFree(ch.res_class); if (ch.res_name) XFree(ch.res_name); - c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags]; + c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : (c->mon->tagset[c->mon->seltags] & ~SPTAGMASK); } int @@ -1853,6 +1862,10 @@ showhide(Client *c) if (!c) return; if (ISVISIBLE(c)) { + if ((c->tags & SPTAGMASK) && c->isfloating) { + c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2); + c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2); + } /* show clients top down */ XMoveWindow(dpy, c->win, c->x, c->y); if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen) @@ -1968,6 +1981,32 @@ togglefloating(const Arg *arg) } void +togglescratch(const Arg *arg) +{ + Client *c; + unsigned int found = 0; + unsigned int scratchtag = SPTAG(arg->ui); + Arg sparg = {.v = scratchpads[arg->ui].cmd}; + + for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next); + if (found) { + unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag; + if (newtagset) { + selmon->tagset[selmon->seltags] = newtagset; + focus(NULL); + arrange(selmon); + } + if (ISVISIBLE(c)) { + focus(c); + restack(selmon); + } + } else { + selmon->tagset[selmon->seltags] |= scratchtag; + spawn(&sparg); + } +} + +void toggletag(const Arg *arg) { unsigned int newtags;