From 089bb41dab1ec4f1bf13e4f9bc81b3dfadf884d4 Mon Sep 17 00:00:00 2001 From: Sravan Balaji Date: Sun, 22 Sep 2024 21:00:20 -0400 Subject: [PATCH] Add setupenv patch --- README.org | 27 +++++++++++++++++ config.def.h | 5 +++ config.h | 14 +++++++++ dwl.c | 11 +++++++ patches.def.h | 2 ++ patches/setupenv-20240326.patch | 54 +++++++++++++++++++++++++++++++++ 6 files changed, 113 insertions(+) create mode 100644 patches/setupenv-20240326.patch diff --git a/README.org b/README.org index 976d1a3..526627c 100644 --- a/README.org +++ b/README.org @@ -15,12 +15,14 @@ - [[#numlock-capslock][Numlock Capslock]] - [[#per-tag][Per Tag]] - [[#restore-monitor][Restore Monitor]] + - [[#setup-env][Setup Env]] - [[#vanity-gaps][Vanity Gaps]] - [[#warp-cursor][Warp Cursor]] - [[#dwl-configuration][dwl Configuration]] - [[#appearance][Appearance]] - [[#tagging][Tagging]] - [[#logging][Logging]] + - [[#environment-variables][Environment Variables]] - [[#autostart][Autostart]] - [[#window-rules][Window Rules]] - [[#layouts][Layouts]] @@ -129,6 +131,14 @@ Moves clients to their old output when it is reattached. #define RESTORE_MONITOR_PATCH 1 #+END_SRC +** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/setupenv][Setup Env]] + +Allow configuring environment variables in config.h + +#+BEGIN_SRC c :tangle patches.def.h +#define SETUPENV_PATCH 1 +#+END_SRC + ** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/vanitygaps][Vanity Gaps]] Adds (inner) gaps between client windows and (outer) gaps between windows and the screen edge in a flexible manner. @@ -197,6 +207,23 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca static int log_level = WLR_ERROR; #+END_SRC +** Environment Variables +#+BEGIN_SRC c :tangle config.h +#if SETUPENV_PATCH +static const Env envs[] = { + /* variable value */ + { "TERM", "xterm-256color" }, + { "SHELL", "/bin/fish" }, + { "EDITOR", "emacs" }, + { "GIT_EDITOR", "emacs" }, + { "BROWSER", "vivaldi-stable" }, + { "QT_QPA_PLATFORMTHEME", "qt6ct" }, + { "_JAVA_AWT_WM_NONREPARENTING", "1" }, + { "XDG_CURRENT_DESKTOP", "wlroots" }, +}; +#endif // SETUPENV_PATCH +#+END_SRC + ** Autostart #+BEGIN_SRC c :tangle config.h diff --git a/config.def.h b/config.def.h index a0c3480..4faab85 100644 --- a/config.def.h +++ b/config.def.h @@ -26,6 +26,11 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca /* logging */ static int log_level = WLR_ERROR; +static const Env envs[] = { + /* variable value */ + { "XDG_CURRENT_DESKTOP", "wlroots" }, +}; + /* Autostart */ static const char *const autostart[] = { "wbg", "/path/to/your/image", NULL, diff --git a/config.h b/config.h index 311a72b..6349459 100644 --- a/config.h +++ b/config.h @@ -28,6 +28,20 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca static int log_level = WLR_ERROR; +#if SETUPENV_PATCH +static const Env envs[] = { + /* variable value */ + { "TERM", "xterm-256color" }, + { "SHELL", "/bin/fish" }, + { "EDITOR", "emacs" }, + { "GIT_EDITOR", "emacs" }, + { "BROWSER", "vivaldi-stable" }, + { "QT_QPA_PLATFORMTHEME", "qt6ct" }, + { "_JAVA_AWT_WM_NONREPARENTING", "1" }, + { "XDG_CURRENT_DESKTOP", "wlroots" }, +}; +#endif // SETUPENV_PATCH + #if AUTOSTART_PATCH static const char *const autostart[] = { /* Display / Compositor Setup */ diff --git a/dwl.c b/dwl.c index 44f40f4..ba0c128 100644 --- a/dwl.c +++ b/dwl.c @@ -276,6 +276,13 @@ typedef struct { int monitor; } Rule; +#if SETUPENV_PATCH +typedef struct { + const char *variable; + const char *value; +} Env; +#endif // SETUPENV_PATCH + typedef struct { struct wlr_scene_tree *scene; @@ -2880,6 +2887,10 @@ run(char *startup_cmd) if (!socket) die("startup: display_add_socket_auto"); setenv("WAYLAND_DISPLAY", socket, 1); +#if SETUPENV_PATCH + for (size_t i = 0; i < LENGTH(envs); i++) + setenv(envs[i].variable, envs[i].value, 1); +#endif // SETUPENV_PATCH /* Start the backend. This will enumerate outputs and inputs, become the DRM * master, etc */ diff --git a/patches.def.h b/patches.def.h index 3f775bf..c2cd99e 100644 --- a/patches.def.h +++ b/patches.def.h @@ -14,6 +14,8 @@ #define RESTORE_MONITOR_PATCH 1 +#define SETUPENV_PATCH 1 + #define VANITYGAPS_PATCH 1 #define WARPCURSOR_PATCH 1 diff --git a/patches/setupenv-20240326.patch b/patches/setupenv-20240326.patch new file mode 100644 index 0000000..17d2ad4 --- /dev/null +++ b/patches/setupenv-20240326.patch @@ -0,0 +1,54 @@ +From 11ee2fc23ef5728d1e132f338c08a7805c6109b2 Mon Sep 17 00:00:00 2001 +From: choc +Date: Tue, 26 Mar 2024 21:02:16 +0800 +Subject: [PATCH] implement setupenv + +--- + config.def.h | 5 +++++ + dwl.c | 7 +++++++ + 2 files changed, 12 insertions(+) + +diff --git a/config.def.h b/config.def.h +index 9009517..b16189a 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -20,6 +20,11 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca + /* logging */ + static int log_level = WLR_ERROR; + ++static const Env envs[] = { ++ /* variable value */ ++ { "XDG_CURRENT_DESKTOP", "wlroots" }, ++}; ++ + static const Rule rules[] = { + /* app_id title tags mask isfloating monitor */ + /* examples: +diff --git a/dwl.c b/dwl.c +index 5867b0c..b7d522b 100644 +--- a/dwl.c ++++ b/dwl.c +@@ -230,6 +230,11 @@ typedef struct { + int monitor; + } Rule; + ++typedef struct { ++ const char *variable; ++ const char *value; ++} Env; ++ + typedef struct { + struct wlr_scene_tree *scene; + +@@ -2066,6 +2071,8 @@ run(char *startup_cmd) + if (!socket) + die("startup: display_add_socket_auto"); + setenv("WAYLAND_DISPLAY", socket, 1); ++ for (size_t i = 0; i < LENGTH(envs); i++) ++ setenv(envs[i].variable, envs[i].value, 1); + + /* Start the backend. This will enumerate outputs and inputs, become the DRM + * master, etc */ +-- +2.44.0 +