Add setupenv patch

This commit is contained in:
Sravan Balaji
2024-09-22 21:00:20 -04:00
parent 8c9439a119
commit 089bb41dab
6 changed files with 113 additions and 0 deletions

View File

@@ -15,12 +15,14 @@
- [[#numlock-capslock][Numlock Capslock]] - [[#numlock-capslock][Numlock Capslock]]
- [[#per-tag][Per Tag]] - [[#per-tag][Per Tag]]
- [[#restore-monitor][Restore Monitor]] - [[#restore-monitor][Restore Monitor]]
- [[#setup-env][Setup Env]]
- [[#vanity-gaps][Vanity Gaps]] - [[#vanity-gaps][Vanity Gaps]]
- [[#warp-cursor][Warp Cursor]] - [[#warp-cursor][Warp Cursor]]
- [[#dwl-configuration][dwl Configuration]] - [[#dwl-configuration][dwl Configuration]]
- [[#appearance][Appearance]] - [[#appearance][Appearance]]
- [[#tagging][Tagging]] - [[#tagging][Tagging]]
- [[#logging][Logging]] - [[#logging][Logging]]
- [[#environment-variables][Environment Variables]]
- [[#autostart][Autostart]] - [[#autostart][Autostart]]
- [[#window-rules][Window Rules]] - [[#window-rules][Window Rules]]
- [[#layouts][Layouts]] - [[#layouts][Layouts]]
@@ -129,6 +131,14 @@ Moves clients to their old output when it is reattached.
#define RESTORE_MONITOR_PATCH 1 #define RESTORE_MONITOR_PATCH 1
#+END_SRC #+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]] ** [[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. 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; static int log_level = WLR_ERROR;
#+END_SRC #+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 ** Autostart
#+BEGIN_SRC c :tangle config.h #+BEGIN_SRC c :tangle config.h

View File

@@ -26,6 +26,11 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca
/* logging */ /* logging */
static int log_level = WLR_ERROR; static int log_level = WLR_ERROR;
static const Env envs[] = {
/* variable value */
{ "XDG_CURRENT_DESKTOP", "wlroots" },
};
/* Autostart */ /* Autostart */
static const char *const autostart[] = { static const char *const autostart[] = {
"wbg", "/path/to/your/image", NULL, "wbg", "/path/to/your/image", NULL,

View File

@@ -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; 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 #if AUTOSTART_PATCH
static const char *const autostart[] = { static const char *const autostart[] = {
/* Display / Compositor Setup */ /* Display / Compositor Setup */

11
dwl.c
View File

@@ -276,6 +276,13 @@ typedef struct {
int monitor; int monitor;
} Rule; } Rule;
#if SETUPENV_PATCH
typedef struct {
const char *variable;
const char *value;
} Env;
#endif // SETUPENV_PATCH
typedef struct { typedef struct {
struct wlr_scene_tree *scene; struct wlr_scene_tree *scene;
@@ -2880,6 +2887,10 @@ run(char *startup_cmd)
if (!socket) if (!socket)
die("startup: display_add_socket_auto"); die("startup: display_add_socket_auto");
setenv("WAYLAND_DISPLAY", socket, 1); 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 /* Start the backend. This will enumerate outputs and inputs, become the DRM
* master, etc */ * master, etc */

View File

@@ -14,6 +14,8 @@
#define RESTORE_MONITOR_PATCH 1 #define RESTORE_MONITOR_PATCH 1
#define SETUPENV_PATCH 1
#define VANITYGAPS_PATCH 1 #define VANITYGAPS_PATCH 1
#define WARPCURSOR_PATCH 1 #define WARPCURSOR_PATCH 1

View File

@@ -0,0 +1,54 @@
From 11ee2fc23ef5728d1e132f338c08a7805c6109b2 Mon Sep 17 00:00:00 2001
From: choc <notchoc@proton.me>
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