Skip to content

Commit f86f7cb

Browse files
committed
chore: update flake inputs
- Fixed dwm alpha patch for dwm 6.6 - Fixed breaking change with declarative containers used imperatively NixOS/nixpkgs#427001 - Fixed obsolete options
1 parent ac315ff commit f86f7cb

File tree

6 files changed

+286
-18
lines changed

6 files changed

+286
-18
lines changed

assets/dwm-alpha.patch

Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
diff --git a/config.def.h b/config.def.h
2+
index 81c3fc0..6d5b40c 100644
3+
--- a/config.def.h
4+
+++ b/config.def.h
5+
@@ -12,11 +12,18 @@ static const char col_gray2[] = "#444444";
6+
static const char col_gray3[] = "#bbbbbb";
7+
static const char col_gray4[] = "#eeeeee";
8+
static const char col_cyan[] = "#005577";
9+
+static const unsigned int baralpha = 0xd0;
10+
+static const unsigned int borderalpha = OPAQUE;
11+
static const char *colors[][3] = {
12+
/* fg bg border */
13+
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
14+
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
15+
};
16+
+static const unsigned int alphas[][3] = {
17+
+ /* fg bg border*/
18+
+ [SchemeNorm] = { OPAQUE, baralpha, borderalpha },
19+
+ [SchemeSel] = { OPAQUE, baralpha, borderalpha },
20+
+};
21+
22+
/* tagging */
23+
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
24+
diff --git a/config.mk b/config.mk
25+
index b469a2b..31b21ef 100644
26+
--- a/config.mk
27+
+++ b/config.mk
28+
@@ -23,7 +23,7 @@ FREETYPEINC = /usr/include/freetype2
29+
30+
# includes and libs
31+
INCS = -I${X11INC} -I${FREETYPEINC}
32+
-LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
33+
+LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender
34+
35+
# flags
36+
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
37+
diff --git a/drw.c b/drw.c
38+
index c41e6af..dda50ad 100644
39+
--- a/drw.c
40+
+++ b/drw.c
41+
@@ -47,7 +47,7 @@ utf8decode(const char *s_in, long *u, int *err)
42+
}
43+
44+
Drw *
45+
-drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h)
46+
+drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap)
47+
{
48+
Drw *drw = ecalloc(1, sizeof(Drw));
49+
50+
@@ -56,8 +56,11 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h
51+
drw->root = root;
52+
drw->w = w;
53+
drw->h = h;
54+
- drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
55+
- drw->gc = XCreateGC(dpy, root, 0, NULL);
56+
+ drw->visual = visual;
57+
+ drw->depth = depth;
58+
+ drw->cmap = cmap;
59+
+ drw->drawable = XCreatePixmap(dpy, root, w, h, depth);
60+
+ drw->gc = XCreateGC(dpy, drw->drawable, 0, NULL);
61+
XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
62+
63+
return drw;
64+
@@ -73,7 +76,7 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h)
65+
drw->h = h;
66+
if (drw->drawable)
67+
XFreePixmap(drw->dpy, drw->drawable);
68+
- drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen));
69+
+ drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth);
70+
}
71+
72+
void
73+
@@ -167,21 +170,22 @@ drw_fontset_free(Fnt *font)
74+
}
75+
76+
void
77+
-drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
78+
+drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha)
79+
{
80+
if (!drw || !dest || !clrname)
81+
return;
82+
83+
- if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
84+
- DefaultColormap(drw->dpy, drw->screen),
85+
+ if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap,
86+
clrname, dest))
87+
die("error, cannot allocate color '%s'", clrname);
88+
+
89+
+ dest->pixel = (dest->pixel & 0x00ffffffU) | (alpha << 24);
90+
}
91+
92+
/* Wrapper to create color schemes. The caller has to call free(3) on the
93+
* returned color scheme when done using it. */
94+
Clr *
95+
-drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
96+
+drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount)
97+
{
98+
size_t i;
99+
Clr *ret;
100+
@@ -191,7 +195,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
101+
return NULL;
102+
103+
for (i = 0; i < clrcount; i++)
104+
- drw_clr_create(drw, &ret[i], clrnames[i]);
105+
+ drw_clr_create(drw, &ret[i], clrnames[i], alphas[i]);
106+
return ret;
107+
}
108+
109+
@@ -250,9 +254,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
110+
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
111+
if (w < lpad)
112+
return x + w;
113+
- d = XftDrawCreate(drw->dpy, drw->drawable,
114+
- DefaultVisual(drw->dpy, drw->screen),
115+
- DefaultColormap(drw->dpy, drw->screen));
116+
+ d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap);
117+
x += lpad;
118+
w -= lpad;
119+
}
120+
diff --git a/drw.h b/drw.h
121+
index 6471431..2143533 100644
122+
--- a/drw.h
123+
+++ b/drw.h
124+
@@ -20,6 +20,9 @@ typedef struct {
125+
Display *dpy;
126+
int screen;
127+
Window root;
128+
+ Visual *visual;
129+
+ unsigned int depth;
130+
+ Colormap cmap;
131+
Drawable drawable;
132+
GC gc;
133+
Clr *scheme;
134+
@@ -27,7 +30,7 @@ typedef struct {
135+
} Drw;
136+
137+
/* Drawable abstraction */
138+
-Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
139+
+Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap);
140+
void drw_resize(Drw *drw, unsigned int w, unsigned int h);
141+
void drw_free(Drw *drw);
142+
143+
@@ -39,8 +42,8 @@ unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int
144+
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
145+
146+
/* Colorscheme abstraction */
147+
-void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
148+
-Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
149+
+void drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha);
150+
+Clr *drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount);
151+
152+
/* Cursor abstraction */
153+
Cur *drw_cur_create(Drw *drw, int shape);
154+
diff --git a/dwm.c b/dwm.c
155+
index 4cf07eb..b8e5642 100644
156+
--- a/dwm.c
157+
+++ b/dwm.c
158+
@@ -55,6 +55,7 @@
159+
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
160+
#define TAGMASK ((1 << LENGTH(tags)) - 1)
161+
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
162+
+#define OPAQUE 0xffU
163+
164+
/* enums */
165+
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
166+
@@ -231,6 +232,7 @@ static Monitor *wintomon(Window w);
167+
static int xerror(Display *dpy, XErrorEvent *ee);
168+
static int xerrordummy(Display *dpy, XErrorEvent *ee);
169+
static int xerrorstart(Display *dpy, XErrorEvent *ee);
170+
+static void xinitvisual();
171+
static void zoom(const Arg *arg);
172+
173+
/* variables */
174+
@@ -267,6 +269,11 @@ static Drw *drw;
175+
static Monitor *mons, *selmon;
176+
static Window root, wmcheckwin;
177+
178+
+static int useargb = 0;
179+
+static Visual *visual;
180+
+static int depth;
181+
+static Colormap cmap;
182+
+
183+
/* configuration, allows nested code to access above variables */
184+
#include "config.h"
185+
186+
@@ -1557,7 +1564,8 @@ setup(void)
187+
sw = DisplayWidth(dpy, screen);
188+
sh = DisplayHeight(dpy, screen);
189+
root = RootWindow(dpy, screen);
190+
- drw = drw_create(dpy, screen, root, sw, sh);
191+
+ xinitvisual();
192+
+ drw = drw_create(dpy, screen, root, sw, sh, visual, depth, cmap);
193+
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
194+
die("no fonts could be loaded.");
195+
lrpad = drw->fonts->h;
196+
@@ -1585,7 +1593,7 @@ setup(void)
197+
/* init appearance */
198+
scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
199+
for (i = 0; i < LENGTH(colors); i++)
200+
- scheme[i] = drw_scm_create(drw, colors[i], 3);
201+
+ scheme[i] = drw_scm_create(drw, colors[i], alphas[i], 3);
202+
/* init bars */
203+
updatebars();
204+
updatestatus();
205+
@@ -1820,16 +1828,18 @@ updatebars(void)
206+
Monitor *m;
207+
XSetWindowAttributes wa = {
208+
.override_redirect = True,
209+
- .background_pixmap = ParentRelative,
210+
+ .background_pixel = 0,
211+
+ .border_pixel = 0,
212+
+ .colormap = cmap,
213+
.event_mask = ButtonPressMask|ExposureMask
214+
};
215+
XClassHint ch = {"dwm", "dwm"};
216+
for (m = mons; m; m = m->next) {
217+
if (m->barwin)
218+
continue;
219+
- m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen),
220+
- CopyFromParent, DefaultVisual(dpy, screen),
221+
- CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
222+
+ m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, depth,
223+
+ InputOutput, visual,
224+
+ CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &wa);
225+
XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
226+
XMapRaised(dpy, m->barwin);
227+
XSetClassHint(dpy, m->barwin, &ch);
228+
@@ -2127,6 +2137,43 @@ xerrorstart(Display *dpy, XErrorEvent *ee)
229+
return -1;
230+
}
231+
232+
+void
233+
+xinitvisual()
234+
+{
235+
+ XVisualInfo *infos;
236+
+ XRenderPictFormat *fmt;
237+
+ int nitems;
238+
+ int i;
239+
+
240+
+ XVisualInfo tpl = {
241+
+ .screen = screen,
242+
+ .depth = 32,
243+
+ .class = TrueColor
244+
+ };
245+
+ long masks = VisualScreenMask | VisualDepthMask | VisualClassMask;
246+
+
247+
+ infos = XGetVisualInfo(dpy, masks, &tpl, &nitems);
248+
+ visual = NULL;
249+
+ for(i = 0; i < nitems; i ++) {
250+
+ fmt = XRenderFindVisualFormat(dpy, infos[i].visual);
251+
+ if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) {
252+
+ visual = infos[i].visual;
253+
+ depth = infos[i].depth;
254+
+ cmap = XCreateColormap(dpy, root, visual, AllocNone);
255+
+ useargb = 1;
256+
+ break;
257+
+ }
258+
+ }
259+
+
260+
+ XFree(infos);
261+
+
262+
+ if (! visual) {
263+
+ visual = DefaultVisual(dpy, screen);
264+
+ depth = DefaultDepth(dpy, screen);
265+
+ cmap = DefaultColormap(dpy, screen);
266+
+ }
267+
+}
268+
+
269+
void
270+
zoom(const Arg *arg)
271+
{

flake.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

home/dwm.nix

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,13 @@ in
167167
../assets/dwm-remove-layout-indicator.patch
168168
../assets/dwm-remove-floating-indicator.patch
169169
../assets/dwm-savefloats-alwayscenter.patch
170+
../assets/dwm-alpha.patch
170171

171172
(fetchpatch {
172173
url = "https://dwm.suckless.org/patches/hide_vacant_tags/dwm-hide_vacant_tags-6.4.diff";
173174
hash = "sha256-GIbRW0Inwbp99rsKLfIDGvPwZ3pqihROMBp5vFlHx5Q=";
174175
})
175176

176-
(fetchpatch {
177-
url = "https://dwm.suckless.org/patches/alpha/dwm-alpha-20230401-348f655.diff";
178-
hash = "sha256-ZhuqyDpY+nQQgrjniQ9DNheUgE9o/MUXKaJYRU3Uyl4=";
179-
})
180-
181177
(fetchpatch {
182178
url = "https://dwm.suckless.org/patches/reorganizetags/dwm-reorganizetags-6.2.diff";
183179
hash = "sha256-Fj+cfw+5d7i6UrakMbebhZsfmu8ZfooduQA08STovK4=";

modules/desktop.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ in
9595

9696
settings = {
9797
default_session = {
98-
command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd Hyprland --time-format '%F %R'";
98+
command = "${pkgs.tuigreet}/bin/tuigreet --time --cmd Hyprland --time-format '%F %R'";
9999
user = "greeter";
100100
};
101101

modules/hardware.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ in
4949
services = {
5050
ratbagd.enable = mkIf mouseSettings true;
5151

52-
logind = {
53-
lidSwitch = mkIf lidIgnore "ignore";
54-
extraConfig = "HandlePowerKey=suspend";
52+
logind.settings.Login = {
53+
HandleLidSwitch = mkIf lidIgnore "ignore";
54+
HandlePowerKey = "suspend";
5555
};
5656

5757
interception-tools = {

modules/system.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ in
9696
efi.canTouchEfiVariables = true;
9797
};
9898

99+
enableContainers = true;
99100
blacklistedKernelModules = [ "floppy" ];
100101
};
101102

0 commit comments

Comments
 (0)