Add monchange patch

This commit is contained in:
Benjamin Chausse 2024-08-07 17:36:48 -04:00
parent dcca4aeb7b
commit b537912e45
No known key found for this signature in database
GPG Key ID: 44F94DD6456590C3
2 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,19 @@
### Description
Allows one to configure a script that runs whenever on monitor configuration
change is detected.
This script is declared an Arg (just like any command run by spawn). It
can be configured through `monchange` in your config.h.
As an example usage, one could write a script that automatically configures
the wallpaper on every display.
### Download
- [monchange-0.7](/dwl/dwl-patches/raw/branch/main/patches/monchange/monchange-0.7.patch)
### Authors
- [ChausseBenjamin](https://codeberg.org/ChausseBenjamin)
benjamin@chausse.xyz
whisperwood at [Libera IRC dwl channel](https://web.libera.chat/?channels=#dwl)
whisperwood at [dwl Discord](https://discord.gg/jJxZnrGPWN)

View File

@ -0,0 +1,55 @@
From ddd9c82891bc14fb8de10a157451c5b8472b75e1 Mon Sep 17 00:00:00 2001
From: Benjamin Chausse <benjamin@chausse.xyz>
Date: Wed, 7 Aug 2024 16:52:21 -0400
Subject: [PATCH] Implement monchange trigger script
---
config.def.h | 3 +++
dwl.c | 8 ++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/config.def.h b/config.def.h
index 22d2171..10d3563 100644
--- a/config.def.h
+++ b/config.def.h
@@ -118,6 +118,9 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
+/* script that runs whenever the monitor configuration changes */
+static const Arg monchange = SHCMD("makewall");
+
/* commands */
static const char *termcmd[] = { "foot", NULL };
static const char *menucmd[] = { "wmenu-run", NULL };
diff --git a/dwl.c b/dwl.c
index a2711f6..d18bed5 100644
--- a/dwl.c
+++ b/dwl.c
@@ -752,6 +752,7 @@ closemon(Monitor *m)
}
focusclient(focustop(selmon), 1);
printstatus();
+ spawn(&monchange);
}
void
@@ -1044,10 +1045,13 @@ createmon(struct wl_listener *listener, void *data)
* output (such as DPI, scale factor, manufacturer, etc).
*/
m->scene_output = wlr_scene_output_create(scene, wlr_output);
- if (m->m.x == -1 && m->m.y == -1)
+ if (m->m.x == -1 && m->m.y == -1) {
wlr_output_layout_add_auto(output_layout, wlr_output);
- else
+ } else {
wlr_output_layout_add(output_layout, wlr_output, m->m.x, m->m.y);
+ }
+
+ spawn(&monchange);
}
void
--
2.45.2