From 94f1581be6150a7ff2f25e91aa297f4d56a6f9fd Mon Sep 17 00:00:00 2001 From: temetvince Date: Fri, 11 Sep 2020 22:24:36 -0500 Subject: [PATCH 1/2] Refactored hard coded st terminal strings into a constant --- config.h | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/config.h b/config.h index 3951f8e..6d9554d 100644 --- a/config.h +++ b/config.h @@ -1,5 +1,9 @@ /* See LICENSE file for copyright and license details. */ +/* Constants */ +#define TERMINAL "st" +#define TERM_CAP "St" + /* appearance */ static const unsigned int borderpx = 3; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ @@ -29,8 +33,8 @@ typedef struct { const char *name; const void *cmd; } Sp; -const char *spcmd1[] = {"st", "-n", "spterm", "-g", "120x34", NULL }; -const char *spcmd2[] = {"st", "-n", "spcalc", "-f", "monospace:size=16", "-g", "50x20", "-e", "bc", "-lq", NULL }; +const char *spcmd1[] = {TERMINAL, "-n", "spterm", "-g", "120x34", NULL }; +const char *spcmd2[] = {TERMINAL, "-n", "spcalc", "-f", "monospace:size=16", "-g", "50x20", "-e", "bc", "-lq", NULL }; static Sp scratchpads[] = { /* name cmd */ {"spterm", spcmd1}, @@ -47,7 +51,7 @@ static const Rule rules[] = { */ /* class instance title tags mask isfloating isterminal noswallow monitor */ { "Gimp", NULL, NULL, 1 << 8, 0, 0, 0, -1 }, - { "St", NULL, NULL, 0, 0, 1, 0, -1 }, + { TERM_CAP, NULL, NULL, 0, 0, 1, 0, -1 }, { NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, { NULL, "spterm", NULL, SPTAG(0), 1, 1, 0, -1 }, { NULL, "spcalc", NULL, SPTAG(1), 1, 1, 0, -1 }, @@ -99,7 +103,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", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL }; -static const char *termcmd[] = { "st", NULL }; +static const char *termcmd[] = { TERMINAL, NULL }; #include #include "shiftview.c" @@ -133,11 +137,11 @@ static Key keys[] = { { MODKEY, XK_q, killclient, {0} }, { MODKEY|ShiftMask, XK_q, spawn, SHCMD("sysact") }, { MODKEY, XK_w, spawn, SHCMD("$BROWSER") }, - { MODKEY|ShiftMask, XK_w, spawn, SHCMD("st -e sudo nmtui") }, - { MODKEY, XK_e, spawn, SHCMD("st -e neomutt ; pkill -RTMIN+12 dwmblocks; rmdir ~/.abook") }, - { MODKEY|ShiftMask, XK_e, spawn, SHCMD("st -e abook -C ~/.config/abook/abookrc --datafile ~/.config/abook/addressbook") }, - { MODKEY, XK_r, spawn, SHCMD("st -e lf") }, - { MODKEY|ShiftMask, XK_r, spawn, SHCMD("st -e htop") }, + { MODKEY|ShiftMask, XK_w, spawn, SHCMD(TERMINAL " -e sudo nmtui") }, + { MODKEY, XK_e, spawn, SHCMD(TERMINAL " -e neomutt ; pkill -RTMIN+12 dwmblocks; rmdir ~/.abook") }, + { MODKEY|ShiftMask, XK_e, spawn, SHCMD(TERMINAL " -e abook -C ~/.config/abook/abookrc --datafile ~/.config/abook/addressbook") }, + { MODKEY, XK_r, spawn, SHCMD(TERMINAL " -e lf") }, + { MODKEY|ShiftMask, XK_r, spawn, SHCMD(TERMINAL " -e htop") }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, /* tile */ { MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[1]} }, /* bstack */ { MODKEY, XK_y, setlayout, {.v = &layouts[2]} }, /* spiral */ @@ -186,9 +190,9 @@ static Key keys[] = { /* V is automatically bound above in STACKKEYS */ { MODKEY, XK_b, togglebar, {0} }, /* { MODKEY|ShiftMask, XK_b, spawn, SHCMD("") }, */ - { MODKEY, XK_n, spawn, SHCMD("st -e nvim -c VimwikiIndex") }, - { MODKEY|ShiftMask, XK_n, spawn, SHCMD("st -e newsboat; pkill -RTMIN+6 dwmblocks") }, - { MODKEY, XK_m, spawn, SHCMD("st -e ncmpcpp") }, + { MODKEY, XK_n, spawn, SHCMD(TERMINAL " -e nvim -c VimwikiIndex") }, + { MODKEY|ShiftMask, XK_n, spawn, SHCMD(TERMINAL " -e newsboat; pkill -RTMIN+6 dwmblocks") }, + { MODKEY, XK_m, spawn, SHCMD(TERMINAL " -e ncmpcpp") }, { MODKEY|ShiftMask, XK_m, spawn, SHCMD("pamixer -t; kill -44 $(pidof dwmblocks)") }, { MODKEY, XK_comma, spawn, SHCMD("mpc prev") }, { MODKEY|ShiftMask, XK_comma, spawn, SHCMD("mpc seek 0%") }, @@ -209,7 +213,7 @@ static Key keys[] = { { MODKEY, XK_F1, spawn, SHCMD("groff -mom /usr/local/share/dwm/larbs.mom -Tpdf | zathura -") }, { MODKEY, XK_F2, spawn, SHCMD("tutorialvids") }, { MODKEY, XK_F3, spawn, SHCMD("displayselect") }, - { MODKEY, XK_F4, spawn, SHCMD("st -e pulsemixer; kill -44 $(pidof dwmblocks)") }, + { MODKEY, XK_F4, spawn, SHCMD(TERMINAL " -e pulsemixer; kill -44 $(pidof dwmblocks)") }, { MODKEY, XK_F5, xrdb, {.v = NULL } }, { MODKEY, XK_F6, spawn, SHCMD("torwrap") }, { MODKEY, XK_F7, spawn, SHCMD("td-toggle") }, @@ -238,17 +242,17 @@ static Key keys[] = { { 0, XF86XK_AudioStop, spawn, SHCMD("mpc stop") }, { 0, XF86XK_AudioRewind, spawn, SHCMD("mpc seek -10") }, { 0, XF86XK_AudioForward, spawn, SHCMD("mpc seek +10") }, - { 0, XF86XK_AudioMedia, spawn, SHCMD("st -e ncmpcpp") }, + { 0, XF86XK_AudioMedia, spawn, SHCMD(TERMINAL " -e ncmpcpp") }, { 0, XF86XK_AudioMicMute, spawn, SHCMD("pactl set-source-mute @DEFAULT_SOURCE@ toggle") }, { 0, XF86XK_PowerOff, spawn, SHCMD("sysact") }, - { 0, XF86XK_Calculator, spawn, SHCMD("st -e bc -l") }, + { 0, XF86XK_Calculator, spawn, SHCMD(TERMINAL " -e bc -l") }, { 0, XF86XK_Sleep, spawn, SHCMD("sudo -A zzz") }, { 0, XF86XK_WWW, spawn, SHCMD("$BROWSER") }, - { 0, XF86XK_DOS, spawn, SHCMD("st") }, + { 0, XF86XK_DOS, spawn, SHCMD(TERMINAL) }, { 0, XF86XK_ScreenSaver, spawn, SHCMD("slock & xset dpms force off; mpc pause; pauseallmpv") }, - { 0, XF86XK_TaskPane, spawn, SHCMD("st -e htop") }, - { 0, XF86XK_Mail, spawn, SHCMD("st -e neomutt ; pkill -RTMIN+12 dwmblocks") }, - { 0, XF86XK_MyComputer, spawn, SHCMD("st -e lf /") }, + { 0, XF86XK_TaskPane, spawn, SHCMD(TERMINAL " -e htop") }, + { 0, XF86XK_Mail, spawn, SHCMD(TERMINAL " -e neomutt ; pkill -RTMIN+12 dwmblocks") }, + { 0, XF86XK_MyComputer, spawn, SHCMD(TERMINAL " -e lf /") }, /* { 0, XF86XK_Battery, spawn, SHCMD("") }, */ { 0, XF86XK_Launch1, spawn, SHCMD("xset dpms force off") }, { 0, XF86XK_TouchpadToggle, spawn, SHCMD("(synclient | grep 'TouchpadOff.*1' && synclient TouchpadOff=0) || synclient TouchpadOff=1") }, @@ -288,7 +292,7 @@ static Button buttons[] = { { ClkStatusText, 0, Button5, sigdwmblocks, {.i = 5} }, { ClkStatusText, ShiftMask, Button1, sigdwmblocks, {.i = 6} }, #endif - { ClkStatusText, ShiftMask, Button3, spawn, SHCMD("st -e nvim ~/.local/src/dwmblocks/config.h") }, + { ClkStatusText, ShiftMask, Button3, spawn, SHCMD(TERMINAL " -e nvim ~/.local/src/dwmblocks/config.h") }, { ClkClientWin, MODKEY, Button1, movemouse, {0} }, { ClkClientWin, MODKEY, Button2, defaultgaps, {0} }, { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, From 286c0ccd868c6e267fd08a0d07bd7652227a1fa1 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Sat, 12 Sep 2020 09:33:29 -0400 Subject: [PATCH 2/2] renamed to TERMCLASS --- config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.h b/config.h index ae5119f..747d9a0 100644 --- a/config.h +++ b/config.h @@ -2,7 +2,7 @@ /* Constants */ #define TERMINAL "st" -#define TERM_CAP "St" +#define TERMCLASS "St" /* appearance */ static const unsigned int borderpx = 3; /* border pixel of windows */ @@ -51,7 +51,7 @@ static const Rule rules[] = { */ /* class instance title tags mask isfloating isterminal noswallow monitor */ { "Gimp", NULL, NULL, 1 << 8, 0, 0, 0, -1 }, - { TERM_CAP, NULL, NULL, 0, 0, 1, 0, -1 }, + { TERMCLASS, NULL, NULL, 0, 0, 1, 0, -1 }, { NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, { NULL, "spterm", NULL, SPTAG(0), 1, 1, 0, -1 }, { NULL, "spcalc", NULL, SPTAG(1), 1, 1, 0, -1 },