mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2025-09-10 13:14:57 +00:00

Allows one to call a script whenever the monitor configuration changes (connect/disconnect). As an example, one might want to update the wallpapers on each display. Here is a script that could be called by `monchange` in the `config.h` to achieve this: ``` wallDir="${XDG_CONFIG_HOME:-$HOME}/wallpapers" displays="$(wlr-randr --json | jq -r '.[] | select(.enabled) | .name')" echo "$displays" setDisplay() { case $(ls $wallDir) in *"$1"*) wall=$(ls $wallDir | grep "$1" | head -n 1) ;; *) wall=$(ls $wallDir | grep "default" | head -n 1) ;; esac swaybg --output $1 -m fill --image $wallDir/$wall & } killall swaybg > /dev/null 2>&1 for display in $displays; do setDisplay $display done ```
56 lines
1.6 KiB
Diff
56 lines
1.6 KiB
Diff
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
|
|
|