[wiki] [sites] [dwm][patch][environmentvars] added || Aidan Hall

From: <git_AT_suckless.org>
Date: Sat, 07 Aug 2021 18:51:57 +0200

commit ff972cf36ac511e7f46c773bc60162b24e8270cb
Author: Aidan Hall <aidan.hall_AT_outlook.com>
Date: Sat Aug 7 17:46:51 2021 +0100

    [dwm][patch][environmentvars] added
    
    Added a patch to read the terminal emulator to use
    from an environment variable using getenv(3p) at startup.

diff --git a/dwm.suckless.org/patches/environmentvars/dwm-environmentvars-terminal-20210807-dd4b656.diff b/dwm.suckless.org/patches/environmentvars/dwm-environmentvars-terminal-20210807-dd4b656.diff
new file mode 100644
index 00000000..4b182ca5
--- /dev/null
+++ b/dwm.suckless.org/patches/environmentvars/dwm-environmentvars-terminal-20210807-dd4b656.diff
_AT_@ -0,0 +1,50 @@
+From dd4b656d4f18872736944b98ef1a5e4387de4905 Mon Sep 17 00:00:00 2001
+From: Aidan Hall <aidan.hall_AT_outlook.com>
+Date: Sat, 7 Aug 2021 17:16:12 +0100
+Subject: [PATCH] load TERMINAL environment variable with getenv(3p)
+
+---
+ config.def.h | 2 +-
+ dwm.c | 6 ++++++
+ 2 files changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/config.def.h b/config.def.h
+index a2ac963..5633269 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -58,7 +58,7 @@ static const Layout layouts[] = {
+ /* commands */
+ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
+ static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
+-static const char *termcmd[] = { "st", NULL };
++#define TERMINAL_ENVVAR "TERMINAL"
+
+ static Key keys[] = {
+ /* modifier key function argument */
+diff --git a/dwm.c b/dwm.c
+index 5e4d494..5bfd414 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -262,6 +262,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
+ };
+ static Atom wmatom[WMLast], netatom[NetLast];
+ static int running = 1;
++static char *termcmd[] = { NULL, NULL };
+ static Cur *cursor[CurLast];
+ static Clr **scheme;
+ static Display *dpy;
+_AT_@ -1537,6 +1538,11 @@ setup(void)
+ /* clean up any zombies immediately */
+ sigchld(0);
+
++ /* load environment variable(s) */
++ termcmd[0] = getenv(TERMINAL_ENVVAR);
++ if (termcmd[0] == NULL) {
++ die("couldn't load " TERMINAL_ENVVAR " environment variable.");
++ }
+ /* init screen */
+ screen = DefaultScreen(dpy);
+ sw = DisplayWidth(dpy, screen);
+--
+2.32.0
+
diff --git a/dwm.suckless.org/patches/environmentvars/index.md b/dwm.suckless.org/patches/environmentvars/index.md
new file mode 100644
index 00000000..24d7e6df
--- /dev/null
+++ b/dwm.suckless.org/patches/environmentvars/index.md
_AT_@ -0,0 +1,22 @@
+Environment Variables
+=====================
+
+Description
+-----------
+This patch loads the name of the terminal emulator to be used as `termcmd`
+from the environment variable `TERMINAL` using `getenv(3p)`.
+It may be set as follows:
+
+`$ export TERMINAL="$(which st)"`
+
+The environment variable to use may be changed with the `TERMINAL_ENVVAR`
+preprocessor macro.
+A similar patch could be created for the `dmenucmd`.
+
+Download
+--------
+* [dwm-environmentvars-terminal-20210807-dd4b656.diff](dwm-environmentvars-terminal-20210807-dd4b656.diff)
+
+Author
+------
+* Aidan Hall <aidan.hall_AT_outlook.com>
Received on Sat Aug 07 2021 - 18:51:57 CEST

This archive was generated by hypermail 2.3.0 : Sat Aug 07 2021 - 19:00:46 CEST