Last active
May 23, 2024 19:12
-
-
Save tunalad/2bba81acee2dbebdaa0275fcd4f82493 to your computer and use it in GitHub Desktop.
dwl port of dwm's environmentvar patch `https://dwm.suckless.org/patches/environmentvars/`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 05befebe956d7e42e540bf86d0a6b938f7573e3c Mon Sep 17 00:00:00 2001 | |
From: tunalad <[email protected]> | |
Date: Mon, 6 Nov 2023 22:19:07 +0100 | |
Subject: [PATCH] terminal-envvar patch | |
pretty much clone of dwm's `environmentvars` patch, it loads the name of the terminal emulator to be used as termcmd from the environment variable TERMINAL using getenv(3p). | |
example: | |
```sh | |
$ export TERMINAL="alacritty" | |
``` | |
`https://dwm.suckless.org/patches/environmentvars/` | |
--- | |
config.def.h | 2 +- | |
dwl.c | 7 +++++++ | |
2 files changed, 8 insertions(+), 1 deletion(-) | |
diff --git a/config.def.h b/config.def.h | |
index db0babc..bc54005 100644 | |
--- a/config.def.h | |
+++ b/config.def.h | |
@@ -112,7 +112,7 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA | |
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } | |
/* commands */ | |
-static const char *termcmd[] = { "foot", NULL }; | |
+#define TERMINAL_ENVVAR "TERMINAL" | |
static const char *menucmd[] = { "bemenu-run", NULL }; | |
static const Key keys[] = { | |
diff --git a/dwl.c b/dwl.c | |
index a7d41b0..6baedbc 100644 | |
--- a/dwl.c | |
+++ b/dwl.c | |
@@ -361,6 +361,7 @@ static struct wl_list keyboards; | |
static unsigned int cursor_mode; | |
static Client *grabc; | |
static int grabcx, grabcy; /* client-relative */ | |
+static char * termcmd[] = { NULL, NULL }; | |
static struct wlr_output_layout *output_layout; | |
static struct wlr_box sgeom; | |
@@ -2141,6 +2142,12 @@ setup(void) | |
wlr_log_init(log_level, NULL); | |
+ /* load terminal environment variable */ | |
+ termcmd[0] = getenv(TERMINAL_ENVVAR); | |
+ if (termcmd[0] == NULL) { | |
+ die("couldn't load " TERMINAL_ENVVAR " environment variable."); | |
+ } | |
+ | |
/* The Wayland display is managed by libwayland. It handles accepting | |
* clients from the Unix socket, manging Wayland globals, and so on. */ | |
dpy = wl_display_create(); | |
-- | |
2.42.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment