Add dwm window manager with some initial patches

- Set Mod4 as the mod key and Alacritty as the termcmd.
- Add a patch from suckless.org to hide any vacant tags.
  - https://dwm.suckless.org/patches/hide_vacant_tags
This commit is contained in:
Oliver Davies 2025-01-30 17:38:03 +00:00
parent e66af807b3
commit 4461ad3ca4
8 changed files with 172 additions and 6 deletions

View file

@ -59,7 +59,7 @@
formatter.${system} = pkgs.nixfmt-rfc-style;
overlays = import ./nix/overlays { inherit inputs; };
overlays = import ./nix/overlays { inherit inputs self; };
nixosModules.default = ./nix/modules/nixos;

View file

@ -1,11 +1,10 @@
{ ... }:
{
imports = [
./dwm.nix
./interception-tools.nix
./sound.nix
./xserver.nix
./udev.nix
./xserver.nix
];
services = {

View file

@ -0,0 +1,27 @@
{ pkgs, ... }:
{
services = {
dwm-status = {
enable = true;
order = [
"audio"
"backlight"
"battery"
"cpu_load"
"network"
"time"
];
};
xserver.windowManager.dwm.enable = true;
};
environment.systemPackages = with pkgs; [
dmenu
dmenu-bluetooth
networkmanager_dmenu
st
];
}

View file

@ -1,4 +1,4 @@
{ inputs, ... }:
{ inputs, self, ... }:
{
additions =
@ -9,7 +9,15 @@
pkgs = final;
};
modifications = final: prev: { };
modifications = final: prev: {
dwm = prev.dwm.override {
patches = [
"${self}/patches/dwm/change-mod-key.patch"
"${self}/patches/dwm/change-termcmd.patch"
"${self}/patches/dwm/dwm-hide_vacant_tags-6.4.diff"
];
};
};
stable-packages = final: _prev: {
nixpkgs-2405 = import inputs.nixpkgs-2405 {

View file

@ -0,0 +1,13 @@
diff --git a/config.def.h b/config.def.h
index 9efa774..4412cb1 100644
--- a/config.def.h
+++ b/config.def.h
@@ -45,7 +45,7 @@ static const Layout layouts[] = {
};
/* key definitions */
-#define MODKEY Mod1Mask
+#define MODKEY Mod4Mask
#define TAGKEYS(KEY,TAG) \
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \

View file

@ -0,0 +1,13 @@
diff --git a/config.def.h b/config.def.h
index 9efa774..648336e 100644
--- a/config.def.h
+++ b/config.def.h
@@ -58,7 +58,7 @@ 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 *termcmd[] = { "alacritty", NULL };
static const Key keys[] = {
/* modifier key function argument */

View file

@ -0,0 +1,48 @@
:100644 100644 f1d86b2 0000000 M dwm.c
diff --git a/dwm.c b/dwm.c
index f1d86b2..d41cc14 100644
--- a/dwm.c
+++ b/dwm.c
@@ -433,9 +433,15 @@ buttonpress(XEvent *e)
}
if (ev->window == selmon->barwin) {
i = x = 0;
- do
+ unsigned int occ = 0;
+ for(c = m->clients; c; c=c->next)
+ occ |= c->tags == TAGMASK ? 0 : c->tags;
+ do {
+ /* Do not reserve space for vacant tags */
+ if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
+ continue;
x += TEXTW(tags[i]);
- while (ev->x >= x && ++i < LENGTH(tags));
+ } while (ev->x >= x && ++i < LENGTH(tags));
if (i < LENGTH(tags)) {
click = ClkTagBar;
arg.ui = 1 << i;
@@ -715,19 +721,18 @@ drawbar(Monitor *m)
}
for (c = m->clients; c; c = c->next) {
- occ |= c->tags;
+ occ |= c->tags == TAGMASK ? 0 : c->tags;
if (c->isurgent)
urg |= c->tags;
}
x = 0;
for (i = 0; i < LENGTH(tags); i++) {
+ /* Do not draw vacant tags */
+ if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
+ continue;
w = TEXTW(tags[i]);
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
- if (occ & 1 << i)
- drw_rect(drw, x + boxs, boxs, boxw, boxw,
- m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
- urg & 1 << i);
x += w;
}
w = TEXTW(m->ltsymbol);

View file

@ -0,0 +1,58 @@
diff -up dwm-6.2-original/config.def.h dwm-6.2-modified/config.def.h
--- dwm-6.2-original/config.def.h 2019-02-02 14:55:28.000000000 +0200
+++ dwm-6.2-modified/config.def.h 2019-11-18 19:36:22.515566509 +0200
@@ -26,9 +26,9 @@ static const Rule rules[] = {
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
*/
- /* class instance title tags mask isfloating monitor */
- { "Gimp", NULL, NULL, 0, 1, -1 },
- { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
+ /* class instance title tags mask switchtotag isfloating monitor */
+ { "Gimp", NULL, NULL, 0, 0, 1, -1 },
+ { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1 },
};
/* layout(s) */
diff -up dwm-6.2-original/dwm.c dwm-6.2-modified/dwm.c
--- dwm-6.2-original/dwm.c 2019-02-02 14:55:28.000000000 +0200
+++ dwm-6.2-modified/dwm.c 2019-11-18 19:37:18.792187705 +0200
@@ -92,6 +92,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw;
unsigned int tags;
+ unsigned int switchtotag;
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
Client *next;
Client *snext;
@@ -137,6 +138,7 @@ typedef struct {
const char *instance;
const char *title;
unsigned int tags;
+ unsigned int switchtotag;
int isfloating;
int monitor;
} Rule;
@@ -302,6 +304,11 @@ applyrules(Client *c)
for (m = mons; m && m->num != r->monitor; m = m->next);
if (m)
c->mon = m;
+ if (r->switchtotag) {
+ Arg a = { .ui = r->tags };
+ c->switchtotag = selmon->tagset[selmon->seltags];
+ view(&a);
+ }
}
}
if (ch.res_class)
@@ -1782,6 +1789,10 @@ unmanage(Client *c, int destroyed)
focus(NULL);
updateclientlist();
arrange(m);
+ if (c->switchtotag) {
+ Arg a = { .ui = c->switchtotag };
+ view(&a);
+ }
}
void