* Martti Kühne <[email protected]> [2015-04-28 09:40]: > The initial patch seems to cover edge cases I fail to grasp and > probably doesn't cover all scenarios.
I've implemented URL selection into st, where I need to start dmenu and the browser. See the patch attached. I'm open to push this one to the wiki, but I think the initial one should be included upstream. Cheers Jochen
From 21f0cfd393d4a2456edfbc51b5b8fdf88aa67f25 Mon Sep 17 00:00:00 2001 From: Jochen Sprickerhof <[email protected]> Date: Wed, 25 Sep 2013 09:21:13 +0200 Subject: [PATCH] Add plumbing Default keybord shortcuts (needs urlselect in $PATH): { MODKEY, XK_u, plumb, {.v = "urlselect"} }, { MODKEY|ShiftMask, XK_U, plumb, {.v = "urlselect -c"} }, Based on durlview taken from: https://github.com/muennich/dotfiles/blob/master/bin/durlview --- config.def.h | 2 ++ st.c | 26 ++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100755 plumb diff --git a/config.def.h b/config.def.h index bb5596e..2be63f8 100644 --- a/config.def.h +++ b/config.def.h @@ -128,6 +128,8 @@ static Shortcut shortcuts[] = { { MODKEY|ShiftMask, XK_C, clipcopy, {.i = 0} }, { MODKEY|ShiftMask, XK_V, clippaste, {.i = 0} }, { MODKEY, XK_Num_Lock, numlock, {.i = 0} }, + { MODKEY, XK_u, plumb, {.v = "urlselect"} }, + { MODKEY|ShiftMask, XK_U, plumb, {.v = "urlselect -c"} }, }; /* diff --git a/st.c b/st.c index 300cab6..e432408 100644 --- a/st.c +++ b/st.c @@ -317,6 +317,7 @@ static void clipcopy(const Arg *); static void clippaste(const Arg *); static void numlock(const Arg *); static void selpaste(const Arg *); +static void plumb(const Arg *); static void xzoom(const Arg *); static void xzoomabs(const Arg *); static void xzoomreset(const Arg *); @@ -1331,6 +1332,31 @@ ttynew(void) { } void +plumb(const Arg *arg) { + char *ptr; + char str[UTF_SIZ]; + int y; + Glyph *gp, *last; + FILE *d; + + d = popen(arg->v, "w"); + + for(y = 0; y < term.row; y++) { + gp = &term.line[y][0]; + last = &term.line[y][term.col-1]; + + for( ; gp <= last; ++gp) { + ptr = str; + ptr += utf8encode(gp->u, ptr); + *ptr = 0; + fputs(str, d); + } + } + + pclose(d); +} + +void ttyread(void) { static char buf[BUFSIZ]; static int buflen = 0; -- 2.1.4
#!/bin/sh
input=$(grep -Eo "((https?|ftp|git|file|mailto)[.:][^]
,;\"'<>\):]*|www\.[-a-z0-9.]+)[^] .,;\"'<>\):]" | tac | dmenu -l 10 -i)
if [ $? -eq 0 -a -n "$input" ]; then
case "$1" in
"-c")
echo -n "$input" | xclip
;;
*)
surf "$input" &
;;
esac
fi
signature.asc
Description: Digital signature
