From b537912e45411689d7f39080057e4aa8868ca7d6 Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Wed, 7 Aug 2024 17:36:48 -0400 Subject: [PATCH] Add monchange patch --- patches/monchange/README.md | 19 +++++++++ patches/monchange/monchange-0.7.patch | 55 +++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 patches/monchange/README.md create mode 100644 patches/monchange/monchange-0.7.patch diff --git a/patches/monchange/README.md b/patches/monchange/README.md new file mode 100644 index 0000000..9465f79 --- /dev/null +++ b/patches/monchange/README.md @@ -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) diff --git a/patches/monchange/monchange-0.7.patch b/patches/monchange/monchange-0.7.patch new file mode 100644 index 0000000..b471433 --- /dev/null +++ b/patches/monchange/monchange-0.7.patch @@ -0,0 +1,55 @@ +From ddd9c82891bc14fb8de10a157451c5b8472b75e1 Mon Sep 17 00:00:00 2001 +From: Benjamin Chausse +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 +