Add plumbing support for 'h'TML "URL:" links - sacc - sacc(omys), simple consol… | |
git clone git://bitreich.org/sacc/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65… | |
Log | |
Files | |
Refs | |
Tags | |
LICENSE | |
--- | |
commit 92b222eb21149fa7fcd4044f53b2139d10527a1a | |
parent bdb2f6a27c4d8e74a49c7ca2764207a1f63b3646 | |
Author: Quentin Rameau <[email protected]> | |
Date: Tue, 18 Jul 2017 11:34:52 +0200 | |
Add plumbing support for 'h'TML "URL:" links | |
Diffstat: | |
M sacc.c | 15 ++++++++++++++- | |
1 file changed, 14 insertions(+), 1 deletion(-) | |
--- | |
diff --git a/sacc.c b/sacc.c | |
@@ -438,6 +438,19 @@ searchselector(Item *item) | |
return selector; | |
} | |
+static void | |
+plumb(char *url) | |
+{ | |
+ switch (fork()) { | |
+ case -1: | |
+ fprintf(stderr, "Couldn't fork.\n"); | |
+ return; | |
+ case 0: | |
+ if (execlp("xdg-open", "xdg-open", url, NULL) < 0) | |
+ die("execlp: %s", strerror(errno)); | |
+ } | |
+} | |
+ | |
static int | |
dig(Item *entry, Item *item) | |
{ | |
@@ -450,7 +463,7 @@ dig(Item *entry, Item *item) | |
switch (item->type) { | |
case 'h': /* fallthrough */ | |
if (!strncmp(item->selector, "URL:", 4)) { | |
- item->dat = item->selector+4; | |
+ plumb(item->selector+4); | |
return 0; | |
} | |
case '0': |