You are not logged in.
Hello,
I've been patching and customizing DWM to my likings but there's one thing I didn't manage to find. I've seen several persons ask it before but never got a working reply. I am looking for a way to focus the last active window. Not the "view" function which opens last used tag, but a way to switch the focus between the two last active windows, no matter in which tag they are. Those two last windows could be in the same tag, it would then switch focus between the two apps inside the same tag, or in different tags and it would swap between the tags giving focus to each app.
Did you see a patch to achieve something like this?
Thank you in advance
Offline
Hi, i'm looking for a patch that will make floating window, when it's switched from tiled to floating, centered and resized to become smaller. Thx for help.
Offline
Hi, i'm looking for a patch that will make floating window, when it's switched from tiled to floating, centered and resized to become smaller. Thx for help.
That's what you are looking for.
https://dwm.suckless.org/patches/save_floats
It resizes the windows to their original size and places them centered. I use it all the time.
Offline
Hello,
I've been patching and customizing DWM to my likings but there's one thing I didn't manage to find. I've seen several persons ask it before but never got a working reply. I am looking for a way to focus the last active window. Not the "view" function which opens last used tag, but a way to switch the focus between the two last active windows, no matter in which tag they are. Those two last windows could be in the same tag, it would then switch focus between the two apps inside the same tag, or in different tags and it would swap between the tags giving focus to each app.
Did you see a patch to achieve something like this?
Thank you in advance
I'm very sure I've had such a patch applied a few years ago but cannot remember its name. Have you tried all patches on https://dwm.suckless.org/patches ?
edit: That one? https://dwm.suckless.org/patches/swapfocus
Last edited by sekret (2021-11-24 17:25:21)
Offline
I have one inconvenience using dwm since I recently started using transparent terminal. The monocle layout is actually displaying windows behind the current one and that is quite distracting.
Is there a way to use monocle layout with multiple transparent windows stacked without background windows being shown?
Offline
Alfodr, either use pseudo-transparency rather than real transparency with the added benefit of it using fewer resource (cpu / ram), or edit the monocole layout function to only place the first window in monocle position, and all the others off screen.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
@Trilby I do not know how to make edits in monocle function. I would guess when we are iterating through clients, I would need to somehow set 0 size or something to all but front window (monitor->sel is first maybe?)
Offline
Untested, but this should do it:
--- old/dwm.c
+++ new/dwm.c
@@ -1115,8 +1115,10 @@
n++;
if (n > 0) /* override layout symbol */
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
- for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
- resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
+ c = nexttiled(m->clients);
+ resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
+ for (; c; c = nexttiled(c->next))
+ XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y);
}
void
EDIT: in hindsight, the first client from "nexttiled" may be the first in the stack, but not the focused window. If that is the case, then the resize would have to be applied to a different client prehaps m->sel ... it's been ages since I messed with dwm code. Though if there are floating windows, m->sel might be one of them ... So this is probably better:
--- old/dwm.c
+++ new/dwm.c
@@ -1116,7 +1116,8 @@
if (n > 0) /* override layout symbol */
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
- resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
+ if (c == m->sel) resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
+ else XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y);
}
void
Last edited by Trilby (2021-12-24 20:53:45)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
First code was hiding all but I was able to cycle between invisible windows and enter text. The second one is looking right but I cannot rotate stack. If I close he first one, next is placed ok
Offline
i have been wanting and trying to create a patch that checks my charger status and if its plugged in the color-theme of dwm will be blue but if it is unplugged then it will turn the theme of dwm to red, heres the "patch" i made
------------------- config.def.h
--- original.h 2025-03-27 15:14:53.097312042 +0500
+++ config.def.h 2025-06-15 14:51:21.240599830 +0500
@@ -1,100 +1,150 @@
/* See LICENSE file for copyright and license details. */
/* appearance */
-static const unsigned int borderpx = 1; /* border pixel of windows */
-static const unsigned int snap = 32; /* snap pixel */
-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 col_gray1[] = "#222222";
-static const char col_gray2[] = "#444444";
-static const char col_gray3[] = "#bbbbbb";
-static const char col_gray4[] = "#eeeeee";
-static const char col_cyan[] = "#005577";
-static const char *colors[][3] = {
- /* fg bg border */
- [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
- [SchemeSel] = { col_gray4, col_cyan, col_cyan },
+static const unsigned int borderpx = 6; /* border pixel of windows */
+static const unsigned int snap = 32; /* snap pixel */
+static const int showbar = 1; /* 0 means no bar */
+static const int topbar = 1; /* 0 means bottom bar */
+static const char *fonts[] = { "Liberation Mono:bold:size=14" };
+static const char dmenufont[] = "Liberation Mono:bold:size=14";
+
+static const char *blue[] = {
+// text dark light
+ "#FFFFFF", "#0E1C4A", "#3E54BD"
};
+static const char *red[] = {
+// text dark light
+ "#FFFFFF", "#430B07", "#73493D"
+};
+
+static const char **current_theme = blue;
+/*
+static const char *green[] = {
+ "#1A2C12", "#020C02", "#193A0D", "#385C17", "#1B331D"
+};
+*/
------------------- dwm.c
--- original.c 2025-06-15 15:17:35.492684035 +0500
+++ dwm.c 2025-05-25 10:10:31.564985125 +0500
@@ -271,6 +272,49 @@
/* configuration, allows nested code to access above variables */
#include "config.h"
+extern const char **current_theme;
+const char *colors[2][3];
+
+
+void
+update_colors(void) {
+ colors[SchemeNorm][0] = (char *)current_theme[0];
+ colors[SchemeNorm][1] = (char *)current_theme[1];
+ colors[SchemeNorm][2] = (char *)current_theme[2];
+
+ colors[SchemeSel][0] = (char *)current_theme[0];
+ colors[SchemeSel][1] = (char *)current_theme[2];
+ colors[SchemeSel][2] = (char *)current_theme[2];
+}
+
+void
+check_theme(Display *dpy) {
+ char *name = NULL;
+ Window root = DefaultRootWindow(dpy);
+
+ if (XFetchName(dpy, root, &name)) {
+ if (name && strstr(name, "change")) {
+ current_theme = red;
+ update_colors();
+ }
+ XFree(name);
+ }
+}
+
+void *
+theme_checker(void *arg) {
+ Display *dpy_thread = XOpenDisplay(NULL);
+ if (!dpy_thread) return NULL;
+
+ for (;;) {
+ check_theme(dpy_thread);
+ usleep(100000);
+ }
+
+ XCloseDisplay(dpy_thread);
+ return NULL;
+}
+
/* compile-time check if all tags fit into an unsigned int bit array. */
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
@@ -1851,7 +1895,7 @@
}
void
-updateclientlist()
+updateclientlist(void)
{
Client *c;
Monitor *m;
@@ -2152,12 +2198,15 @@
if (!(dpy = XOpenDisplay(NULL)))
die("dwm: cannot open display");
checkotherwm();
+ update_colors();
setup();
#ifdef __OpenBSD__
if (pledge("stdio rpath proc exec", NULL) == -1)
die("pledge");
#endif /* __OpenBSD__ */
scan();
+ pthread_t theme_thread;
+ pthread_create(&theme_thread, NULL, theme_checker, NULL);
run();
cleanup();
XCloseDisplay(dpy);
in the code i have set the default theme to be blue and that works just fine and dwm gets colored correctly on build, even if i change the theme manually, but the theme doesnt change on status change
this is a very specific purpose and im pretty sure that there isnt a patch for this, but if there's someone who knows of a patch that does this or can help me out with this i would really appreciate it, i tried doing this myself but i just cant figure it out
im pretty new to C and dont have any exp working with linux or xorg utils, this is just how far i could get with some AI help
Offline