sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit ff972cf36ac511e7f46c773bc60162b24e8270cb
parent 9f50f257ed7ca399a07dc7965708666998ae2c7c
Author: Aidan Hall <aidan.hall@outlook.com>
Date:   Sat,  7 Aug 2021 17:46:51 +0100

[dwm][patch][environmentvars] added

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

Diffstat:
Adwm.suckless.org/patches/environmentvars/dwm-environmentvars-terminal-20210807-dd4b656.diff | 50++++++++++++++++++++++++++++++++++++++++++++++++++
Adwm.suckless.org/patches/environmentvars/index.md | 22++++++++++++++++++++++
2 files changed, 72 insertions(+), 0 deletions(-)

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 @@ -0,0 +1,50 @@ +From dd4b656d4f18872736944b98ef1a5e4387de4905 Mon Sep 17 00:00:00 2001 +From: Aidan Hall <aidan.hall@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 +@@ -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 +@@ -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; +@@ -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 @@ -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@outlook.com>