sites

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

commit c351deb9f36bb5de240d03902dbc51c4f20cc003
parent a8f0f7c3c0be484b0ddf40d0e1c82618749e8706
Author: FRIGN <dev@frign.de>
Date:   Thu, 17 Sep 2015 16:48:32 +0200

st externalpipe - Fix 0.4.1 and 0.5 diffs, update git-diff

The 0.4.1 and 0.5 diffs were broken for some reason. Remove the
external links to the patches, we want to keep them at home.

Diffstat:
Mst.suckless.org/patches/externalpipe.md | 38+++++++++++++++-----------------------
Mst.suckless.org/patches/st-0.4.1-externalpipe.diff | 28++++++++--------------------
Ast.suckless.org/patches/st-0.5-externalpipe.diff | 109+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dst.suckless.org/patches/st-git-20150824-externalpipe.diff | 75---------------------------------------------------------------------------
Ast.suckless.org/patches/st-git-20150917-externalpipe.diff | 75+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 207 insertions(+), 118 deletions(-)

diff --git a/st.suckless.org/patches/externalpipe.md b/st.suckless.org/patches/externalpipe.md @@ -1,44 +1,36 @@ -External Pipe -============= +externalpipe +============ Description ----------- -This patch lets you write st's screen text out through a pipe, for example, -url-select (below). +This patch lets you write st's screen through a pipe. Example ------- -Bind alt+u to extract all visible urls and present dmenu, to choose and open -said urls: +config.h example, binding Mod1+u to extract all visible URLs and present +dmenu to select and open one: static Shortcut shortcuts[] = { ... { MODKEY, 'u', externalpipe, { .s = "xurls | dmenu -l 10 | xargs -r open" } }, }; - -([xurls][1] and [open][2] are external scripts) +([xurls](https://raw.github.com/bobrippling/perlbin/master/xurls) and +[open](https://github.com/bobrippling/open) are external scripts) Download -------- -* [st-0.4.1-externalpipe.diff][0] -* [st-0.5-externalpipe.diff][3] -* [st-0.6-externalpipe.diff][4] -* [st-git-20150824-externalpipe.diff][5] - -[0]: st-0.4.1-externalpipe.diff -[1]: https://raw.github.com/bobrippling/perlbin/master/xurls -[2]: https://github.com/bobrippling/open -[3]: http://witsquash.com/~marty/st-0.5-externalpipe.diff -[4]: st-0.6-externalpipe.diff -[5]: st-git-20150824-externalpipe.diff +* [st-0.4.1-externalpipe.diff](st-0.4.1-externalpipe.diff) +* [st-0.5-externalpipe.diff](st-0.5-externalpipe.diff) +* [st-0.6-externalpipe.diff](st-0.6-externalpipe.diff) +* [st-git-20150917-externalpipe.diff][st-git-20150917-externalpipe.diff] +Authors +------- -Author ------- - - * Rob Pilling - my name @ gmail + * Rob Pilling - robpilling@gmail.com + * Laslo Hunhold - dev@frign.de (st-0.4.1, st-0.5, st-0.6, st-git-20150917 ports) diff --git a/st.suckless.org/patches/st-0.4.1-externalpipe.diff b/st.suckless.org/patches/st-0.4.1-externalpipe.diff @@ -1,17 +1,8 @@ -From 7982a2d238925028b45d5143db470e408b97469a Mon Sep 17 00:00:00 2001 -From: Rob Pilling <robpilling@gmail.com> -Date: Fri, 20 Dec 2013 12:40:55 +0000 -Subject: [PATCH] Add externalpipe() for piping out screen text - ---- - st.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ - 1 file changed, 68 insertions(+), 6 deletions(-) - diff --git a/st.c b/st.c -index 4fb3311..adef257 100644 +index 686ed5d..697cd43 100644 --- a/st.c +++ b/st.c -@@ -299,6 +299,7 @@ typedef union { +@@ -249,6 +249,7 @@ typedef union { unsigned int ui; float f; const void *v; @@ -19,7 +10,7 @@ index 4fb3311..adef257 100644 } Arg; typedef struct { -@@ -313,6 +314,7 @@ static void clippaste(const Arg *); +@@ -263,6 +264,7 @@ static void clippaste(const Arg *); static void numlock(const Arg *); static void selpaste(const Arg *); static void xzoom(const Arg *); @@ -27,14 +18,14 @@ index 4fb3311..adef257 100644 /* Config.h for applying patches and the configuration. */ #include "config.h" -@@ -1204,15 +1206,22 @@ execsh(void) { +@@ -1024,15 +1026,22 @@ execsh(void) { void sigchld(int a) { int stat = 0; + pid_t r; - if(waitpid(pid, &stat, 0) < 0) -- die("Waiting for pid %hd failed: %s\n", pid, SERRNO); +- die("Waiting for pid %hd failed: %s\n", pid, SERRNO); + r = wait(&stat); + if(r < 0) + die("wait(): %s\n", SERRNO); @@ -44,7 +35,7 @@ index 4fb3311..adef257 100644 - } else { - exit(EXIT_FAILURE); + if(r == pid){ -+ /* _the_ sub porcess */ ++ /* _the_ sub process */ + if(WIFEXITED(stat)) { + exit(WEXITSTATUS(stat)); + } else { @@ -56,7 +47,7 @@ index 4fb3311..adef257 100644 } void -@@ -2928,6 +2937,59 @@ xzoom(const Arg *arg) { +@@ -2593,6 +2602,59 @@ xzoom(const Arg *arg) { } void @@ -114,8 +105,5 @@ index 4fb3311..adef257 100644 + +void xinit(void) { + XSetWindowAttributes attrs; XGCValues gcvalues; - Cursor cursor; --- -1.7.10.4 - diff --git a/st.suckless.org/patches/st-0.5-externalpipe.diff b/st.suckless.org/patches/st-0.5-externalpipe.diff @@ -0,0 +1,109 @@ +diff --git a/st.c b/st.c +index 392f12d..31660c8 100644 +--- a/st.c ++++ b/st.c +@@ -301,6 +301,7 @@ typedef union { + unsigned int ui; + float f; + const void *v; ++ const char *s; + } Arg; + + typedef struct { +@@ -315,6 +316,7 @@ static void clippaste(const Arg *); + static void numlock(const Arg *); + static void selpaste(const Arg *); + static void xzoom(const Arg *); ++static void externalpipe(const Arg *); + static void printsel(const Arg *); + static void printscreen(const Arg *) ; + static void toggleprinter(const Arg *); +@@ -1179,15 +1181,22 @@ execsh(void) { + void + sigchld(int a) { + int stat = 0; ++ pid_t r; + +- if(waitpid(pid, &stat, 0) < 0) +- die("Waiting for pid %hd failed: %s\n", pid, SERRNO); ++ r = wait(&stat); ++ if(r < 0) ++ die("wait(): %s\n", strerror(errno)); + +- if(WIFEXITED(stat)) { +- exit(WEXITSTATUS(stat)); +- } else { +- exit(EXIT_FAILURE); ++ if(r == pid){ ++ /* _the_ sub process */ ++ if(WIFEXITED(stat)) { ++ exit(WEXITSTATUS(stat)); ++ } else { ++ exit(EXIT_FAILURE); ++ } + } ++ ++ /* something else we've forked out */ + } + + void +@@ -2982,6 +2991,59 @@ xzoom(const Arg *arg) { + } + + void ++externalpipe(const Arg *arg) ++{ ++ int to[2]; /* 0 = read, 1 = write */ ++ pid_t child; ++ int y, x; ++ void (*oldsigpipe)(int); ++ ++ if(pipe(to) == -1) ++ return; ++ ++ /* sigchld() handles this */ ++ switch((child = fork())){ ++ case -1: ++ close(to[0]), close(to[1]); ++ return; ++ case 0: ++ /* child */ ++ close(to[1]); ++ dup2(to[0], STDIN_FILENO); /* 0<&to */ ++ close(to[0]); ++ execvp( ++ "sh", ++ (char *const []){ ++ "/bin/sh", ++ "-c", ++ (char *)arg->s, ++ 0 ++ }); ++ exit(127); ++ } ++ ++ /* parent */ ++ close(to[0]); ++ /* ignore sigpipe for now, in case child exits early */ ++ oldsigpipe = signal(SIGPIPE, SIG_IGN); ++ ++ for(y = 0; y < term.row; y++){ ++ for(x = 0; x < term.col; x++){ ++ if(write(to[1], term.line[y][x].c, 1) == -1) ++ goto done; ++ } ++ if(write(to[1], "\n", 1) == -1) ++ break; ++ } ++ ++done: ++ close(to[1]); ++ ++ /* restore */ ++ signal(SIGPIPE, oldsigpipe); ++} ++ ++void + xinit(void) { + XGCValues gcvalues; + Cursor cursor; diff --git a/st.suckless.org/patches/st-git-20150824-externalpipe.diff b/st.suckless.org/patches/st-git-20150824-externalpipe.diff @@ -1,75 +0,0 @@ -diff --git a/st.c b/st.c -index 35a840b..bb2dd17 100644 ---- a/st.c -+++ b/st.c -@@ -327,6 +327,7 @@ static void clipcopy(const Arg *); - static void clippaste(const Arg *); - static void numlock(const Arg *); - static void selpaste(const Arg *); -+static void externalpipe(const Arg *); - static void xzoom(const Arg *); - static void xzoomabs(const Arg *); - static void xzoomreset(const Arg *); -@@ -2888,6 +2889,62 @@ eschandle(uchar ascii) - } - - void -+externalpipe(const Arg *arg) -+{ -+ int to[2]; /* 0 = read, 1 = write */ -+ pid_t child; -+ int n; -+ void (*oldsigpipe)(int); -+ char buf[UTF_SIZ]; -+ Glyph *bp, *end; -+ -+ if(pipe(to) == -1) -+ return; -+ -+ /* sigchld() handles this */ -+ switch(child = fork()){ -+ case -1: -+ close(to[0]), close(to[1]); -+ return; -+ case 0: -+ /* child */ -+ close(to[1]); -+ dup2(to[0], STDIN_FILENO); /* 0<&to */ -+ close(to[0]); -+ execvp( -+ "sh", -+ (char *const []){ -+ "/bin/sh", -+ "-c", -+ (char *)arg->v, -+ 0 -+ }); -+ exit(127); -+ } -+ -+ /* parent */ -+ close(to[0]); -+ /* ignore sigpipe for now, in case child exits early */ -+ oldsigpipe = signal(SIGPIPE, SIG_IGN); -+ -+ for(n = 0; n < term.row; n++){ -+ bp = &term.line[n][0]; -+ end = &bp[MIN(tlinelen(n), term.col) - 1]; -+ if(bp != end || bp->u != ' ') -+ for(; bp <= end; ++bp) -+ if(xwrite(to[1], buf, utf8encode(bp->u, buf)) < 0) -+ break; -+ if(xwrite(to[1], "\n", 1) < 0) -+ break; -+ } -+ -+ close(to[1]); -+ -+ /* restore */ -+ signal(SIGPIPE, oldsigpipe); -+} -+ -+void - tputc(Rune u) - { - char c[UTF_SIZ]; diff --git a/st.suckless.org/patches/st-git-20150917-externalpipe.diff b/st.suckless.org/patches/st-git-20150917-externalpipe.diff @@ -0,0 +1,75 @@ +diff --git a/st.c b/st.c +index bd8b815..a43e615 100644 +--- a/st.c ++++ b/st.c +@@ -328,6 +328,7 @@ static void clipcopy(const Arg *); + static void clippaste(const Arg *); + static void numlock(const Arg *); + static void selpaste(const Arg *); ++static void externalpipe(const Arg *); + static void xzoom(const Arg *); + static void xzoomabs(const Arg *); + static void xzoomreset(const Arg *); +@@ -2920,6 +2921,62 @@ eschandle(uchar ascii) + } + + void ++externalpipe(const Arg *arg) ++{ ++ int to[2]; /* 0 = read, 1 = write */ ++ pid_t child; ++ int n; ++ void (*oldsigpipe)(int); ++ char buf[UTF_SIZ]; ++ Glyph *bp, *end; ++ ++ if(pipe(to) == -1) ++ return; ++ ++ /* sigchld() handles this */ ++ switch(child = fork()){ ++ case -1: ++ close(to[0]), close(to[1]); ++ return; ++ case 0: ++ /* child */ ++ close(to[1]); ++ dup2(to[0], STDIN_FILENO); /* 0<&to */ ++ close(to[0]); ++ execvp( ++ "sh", ++ (char *const []){ ++ "/bin/sh", ++ "-c", ++ (char *)arg->v, ++ 0 ++ }); ++ exit(127); ++ } ++ ++ /* parent */ ++ close(to[0]); ++ /* ignore sigpipe for now, in case child exits early */ ++ oldsigpipe = signal(SIGPIPE, SIG_IGN); ++ ++ for(n = 0; n < term.row; n++){ ++ bp = &term.line[n][0]; ++ end = &bp[MIN(tlinelen(n), term.col) - 1]; ++ if(bp != end || bp->u != ' ') ++ for(; bp <= end; ++bp) ++ if(xwrite(to[1], buf, utf8encode(bp->u, buf)) < 0) ++ break; ++ if(xwrite(to[1], "\n", 1) < 0) ++ break; ++ } ++ ++ close(to[1]); ++ ++ /* restore */ ++ signal(SIGPIPE, oldsigpipe); ++} ++ ++void + tputc(Rune u) + { + char c[UTF_SIZ];