summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile5
-rw-r--r--config.h7
-rwxr-xr-xst-copyout1
-rwxr-xr-xst-urlhandler15
-rw-r--r--x.c4
6 files changed, 24 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index 18c21b0..faeef69 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@ st.o
x.o
pkg/
*.pkg.tar.xz
+patches
diff --git a/Makefile b/Makefile
index a836907..39f757f 100644
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,7 @@ st: $(OBJ)
$(CC) -o $@ $(OBJ) $(STLDFLAGS)
clean:
- rm -f st $(OBJ) st-$(VERSION).tar.gz
+ rm -f st $(OBJ) st-$(VERSION).tar.gz *.orig *.rej
dist: clean
mkdir -p st-$(VERSION)
@@ -44,8 +44,10 @@ install: st
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp -f st $(DESTDIR)$(PREFIX)/bin
cp -f st-copyout $(DESTDIR)$(PREFIX)/bin
+ cp -f st-urlhandler $(DESTDIR)$(PREFIX)/bin
chmod 755 $(DESTDIR)$(PREFIX)/bin/st
chmod 755 $(DESTDIR)$(PREFIX)/bin/st-copyout
+ chmod 755 $(DESTDIR)$(PREFIX)/bin/st-urlhandler
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
sed "s/VERSION/$(VERSION)/g" < st.1 > $(DESTDIR)$(MANPREFIX)/man1/st.1
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/st.1
@@ -55,6 +57,7 @@ install: st
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/st
rm -f $(DESTDIR)$(PREFIX)/bin/st-copyout
+ rm -f $(DESTDIR)$(PREFIX)/bin/st-urlhandler
rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1
.PHONY: all options clean dist install uninstall
diff --git a/config.h b/config.h
index b0400bd..8ddd69c 100644
--- a/config.h
+++ b/config.h
@@ -221,9 +221,7 @@ MouseKey mkeys[] = {
{ Button5, TERMMOD, zoom, {.f = -1} },
};
-static char *openurlcmd[] = { "/bin/sh", "-c",
- "tmp=$(sed 's/.*│//g' | tr -d '\n' | grep -aEo '(((http|https)://|www\\.)[a-zA-Z0-9.]*[:]?[a-zA-Z0-9./&%?$#=_-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)'| uniq | sed 's/^www./http:\\/\\/www\\./g');IFS=; [ ! -z $tmp ] && echo $tmp | dmenu -i -p 'Follow which url?' -l 10 | xargs -r xdg-open",
- "externalpipe", NULL };
+static char *openurlcmd[] = { "/bin/sh", "-c", "st-urlhandler", "externalpipe", NULL };
static char *copyurlcmd[] = { "/bin/sh", "-c",
"tmp=$(sed 's/.*│//g' | tr -d '\n' | grep -aEo '(((http|https)://|www\\.)[a-zA-Z0-9.]*[:]?[a-zA-Z0-9./&%?$#=_-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)' | uniq | sed 's/^www./http:\\/\\/www\\./g' ); IFS=; [ ! -z $tmp ] && echo $tmp | dmenu -i -p 'Copy which url?' -l 10 | tr -d '\n' | xclip -selection clipboard",
@@ -240,10 +238,9 @@ static Shortcut shortcuts[] = {
{ TERMMOD, XK_Prior, zoom, {.f = +1} },
{ TERMMOD, XK_Next, zoom, {.f = -1} },
{ MODKEY, XK_Home, zoomreset, {.f = 0} },
- { ShiftMask, XK_Insert, clippaste, {.i = 0} },
{ MODKEY, XK_c, clipcopy, {.i = 0} },
+ { ShiftMask, XK_Insert, clippaste, {.i = 0} },
{ MODKEY, XK_v, clippaste, {.i = 0} },
- { MODKEY, XK_p, selpaste, {.i = 0} },
{ XK_ANY_MOD, Button2, selpaste, {.i = 0} },
{ MODKEY, XK_Num_Lock, numlock, {.i = 0} },
{ MODKEY, XK_Control_L, iso14755, {.i = 0} },
diff --git a/st-copyout b/st-copyout
index 8eafc58..0d19e5a 100755
--- a/st-copyout
+++ b/st-copyout
@@ -6,6 +6,7 @@
tmpfile=$(mktemp /tmp/st-cmd-output.XXXXXX)
trap 'rm "$tmpfile"' 0 1 15
sed -n "w $tmpfile"
+sed -i 's/\x0//g' "$tmpfile"
ps1="$(grep "\S" "$tmpfile" | tail -n 1 | sed 's/^\s*//' | cut -d' ' -f1)"
chosen="$(grep -F "$ps1" "$tmpfile" | sed '$ d' | tac | dmenu -p "Copy which command's output?" -i -l 10 | sed 's/[^^]/[&]/g; s/\^/\\^/g')"
eps1="$(echo "$ps1" | sed 's/[^^]/[&]/g; s/\^/\\^/g')"
diff --git a/st-urlhandler b/st-urlhandler
new file mode 100755
index 0000000..5833883
--- /dev/null
+++ b/st-urlhandler
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+urlregex="(((http|https)://|www\\.)[a-zA-Z0-9.]*[:]?[a-zA-Z0-9./@&%?$#=_-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)"
+
+# First remove linebreaks and mutt sidebars:
+urls="$(sed 's/.*│//g' | tr -d '\n' |
+ grep -aEo "$urlregex" | # grep only urls as defined above.
+ uniq | # Ignore neighboring duplicates.
+ sed 's/^www./http:\/\/www\./g')"
+
+[ -z "$urls" ] && exit
+
+chosen="$(echo "$urls" | dmenu -i -p 'Follow which url?' -l 10)"
+
+setsid xdg-open "$chosen" >/dev/null 2>&1 &
diff --git a/x.c b/x.c
index c09392b..93ba648 100644
--- a/x.c
+++ b/x.c
@@ -661,8 +661,6 @@ setsel(char *str, Time t)
XSetSelectionOwner(xw.dpy, XA_PRIMARY, xw.win, t);
if (XGetSelectionOwner(xw.dpy, XA_PRIMARY) != xw.win)
selclear();
-
- clipcopy(NULL);
}
void
@@ -680,7 +678,7 @@ brelease(XEvent *e)
}
if (e->xbutton.button == Button2)
- clippaste(NULL);
+ selpaste(NULL);
else if (e->xbutton.button == Button1)
mousesel(e, 1);
}