dwm-environmentvars-terminal-20210807-dd4b656.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
dwm-environmentvars-terminal-20210807-dd4b656.diff (1632B)
---
1 From dd4b656d4f18872736944b98ef1a5e4387de4905 Mon Sep 17 00:00:00 2001
2 From: Aidan Hall <aidan.hall@outlook.com>
3 Date: Sat, 7 Aug 2021 17:16:12 +0100
4 Subject: [PATCH] load TERMINAL environment variable with getenv(3p)
5
6 ---
7 config.def.h | 2 +-
8 dwm.c | 6 ++++++
9 2 files changed, 7 insertions(+), 1 deletion(-)
10
11 diff --git a/config.def.h b/config.def.h
12 index a2ac963..5633269 100644
13 --- a/config.def.h
14 +++ b/config.def.h
15 @@ -58,7 +58,7 @@ static const Layout layouts[] = {
16 /* commands */
17 static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
18 static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
19 -static const char *termcmd[] = { "st", NULL };
20 +#define TERMINAL_ENVVAR "TERMINAL"
21
22 static Key keys[] = {
23 /* modifier key function argument */
24 diff --git a/dwm.c b/dwm.c
25 index 5e4d494..5bfd414 100644
26 --- a/dwm.c
27 +++ b/dwm.c
28 @@ -262,6 +262,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
29 };
30 static Atom wmatom[WMLast], netatom[NetLast];
31 static int running = 1;
32 +static char *termcmd[] = { NULL, NULL };
33 static Cur *cursor[CurLast];
34 static Clr **scheme;
35 static Display *dpy;
36 @@ -1537,6 +1538,11 @@ setup(void)
37 /* clean up any zombies immediately */
38 sigchld(0);
39
40 + /* load environment variable(s) */
41 + termcmd[0] = getenv(TERMINAL_ENVVAR);
42 + if (termcmd[0] == NULL) {
43 + die("couldn't load " TERMINAL_ENVVAR " environment variable.");
44 + }
45 /* init screen */
46 screen = DefaultScreen(dpy);
47 sw = DisplayWidth(dpy, screen);
48 --
49 2.32.0
50