diff --git a/flake.nix b/flake.nix index 26391f6..16100c8 100644 --- a/flake.nix +++ b/flake.nix @@ -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; diff --git a/nix/hosts/t490/services/default.nix b/nix/hosts/t490/services/default.nix index a2bb5be..0f225b2 100644 --- a/nix/hosts/t490/services/default.nix +++ b/nix/hosts/t490/services/default.nix @@ -1,11 +1,10 @@ -{ ... }: - { imports = [ + ./dwm.nix ./interception-tools.nix ./sound.nix - ./xserver.nix ./udev.nix + ./xserver.nix ]; services = { diff --git a/nix/hosts/t490/services/dwm.nix b/nix/hosts/t490/services/dwm.nix new file mode 100644 index 0000000..f8bc108 --- /dev/null +++ b/nix/hosts/t490/services/dwm.nix @@ -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 + ]; +} diff --git a/nix/overlays/default.nix b/nix/overlays/default.nix index 7d42c2e..3a064cb 100644 --- a/nix/overlays/default.nix +++ b/nix/overlays/default.nix @@ -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 { diff --git a/patches/dwm/change-mod-key.patch b/patches/dwm/change-mod-key.patch new file mode 100644 index 0000000..1aca714 --- /dev/null +++ b/patches/dwm/change-mod-key.patch @@ -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} }, \ diff --git a/patches/dwm/change-termcmd.patch b/patches/dwm/change-termcmd.patch new file mode 100644 index 0000000..cef8397 --- /dev/null +++ b/patches/dwm/change-termcmd.patch @@ -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 */ diff --git a/patches/dwm/dwm-hide_vacant_tags-6.4.diff b/patches/dwm/dwm-hide_vacant_tags-6.4.diff new file mode 100644 index 0000000..42d9c05 --- /dev/null +++ b/patches/dwm/dwm-hide_vacant_tags-6.4.diff @@ -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); diff --git a/patches/dwm/dwm-switchtotag-6.2.diff b/patches/dwm/dwm-switchtotag-6.2.diff new file mode 100644 index 0000000..453f8ef --- /dev/null +++ b/patches/dwm/dwm-switchtotag-6.2.diff @@ -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