Fix externalpipein patch (#78)

* fix externalpipein patch

don't close the slave fd, according to the original patch in
https://lists.suckless.org/hackers/2004/17218.html

* externalpipein patch: add example command

press S-C-M to set the terminal background green dynamically.

Replace `printf ...` with `dynamic-colors cycle` command mentioned in
https://lists.suckless.org/hackers/2004/17218.html to cycle though the
available dynamic color themes.
This commit is contained in:
step 2022-08-16 16:49:10 +02:00 committed by GitHub
parent bcfa5b9b7f
commit 427895a7c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -389,6 +389,12 @@ static MouseShortcut maltshortcuts[] = {
static char *openurlcmd[] = { "/bin/sh", "-c", static char *openurlcmd[] = { "/bin/sh", "-c",
"xurls | dmenu -l 10 -w $WINDOWID | xargs -r open", "xurls | dmenu -l 10 -w $WINDOWID | xargs -r open",
"externalpipe", NULL }; "externalpipe", NULL };
#if EXTERNALPIPEIN_PATCH // example command
static char *setbgcolorcmd[] = { "/bin/sh", "-c",
"printf '\033]11;#008000\007'",
"externalpipein", NULL };
#endif // EXTERNALPIPEIN_PATCH
#endif // EXTERNALPIPE_PATCH #endif // EXTERNALPIPE_PATCH
static Shortcut shortcuts[] = { static Shortcut shortcuts[] = {
@ -425,6 +431,9 @@ static Shortcut shortcuts[] = {
#endif // NEWTERM_PATCH #endif // NEWTERM_PATCH
#if EXTERNALPIPE_PATCH #if EXTERNALPIPE_PATCH
{ TERMMOD, XK_U, externalpipe, { .v = openurlcmd } }, { TERMMOD, XK_U, externalpipe, { .v = openurlcmd } },
#if EXTERNALPIPEIN_PATCH
{ TERMMOD, XK_M, externalpipein, { .v = setbgcolorcmd } },
#endif // EXTERNALPIPEIN_PATCH
#endif // EXTERNALPIPE_PATCH #endif // EXTERNALPIPE_PATCH
#if KEYBOARDSELECT_PATCH #if KEYBOARDSELECT_PATCH
{ TERMMOD, XK_Escape, keyboard_select, { 0 } }, { TERMMOD, XK_Escape, keyboard_select, { 0 } },

5
st.c
View File

@ -1090,15 +1090,16 @@ ttynew(const char *line, char *cmd, const char *out, char **args)
#endif // RIGHTCLICKTOPLUMB_PATCH #endif // RIGHTCLICKTOPLUMB_PATCH
die("pledge\n"); die("pledge\n");
#endif #endif
close(s);
cmdfd = m;
#if EXTERNALPIPEIN_PATCH && EXTERNALPIPE_PATCH #if EXTERNALPIPEIN_PATCH && EXTERNALPIPE_PATCH
csdfd = s; csdfd = s;
cmdfd = m;
memset(&sa, 0, sizeof(sa)); memset(&sa, 0, sizeof(sa));
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
sa.sa_handler = sigchld; sa.sa_handler = sigchld;
sigaction(SIGCHLD, &sa, NULL); sigaction(SIGCHLD, &sa, NULL);
#else #else
close(s);
cmdfd = m;
signal(SIGCHLD, sigchld); signal(SIGCHLD, sigchld);
#endif // EXTERNALPIPEIN_PATCH #endif // EXTERNALPIPEIN_PATCH
break; break;