New approach to url opening.
This commit is contained in:
parent
5957ed5673
commit
a85fe068bd
4 changed files with 7 additions and 27 deletions
|
@ -44,9 +44,7 @@ dist: clean
|
|||
install: st
|
||||
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
||||
cp -f st $(DESTDIR)$(PREFIX)/bin
|
||||
cp -f st-url $(DESTDIR)$(PREFIX)/bin
|
||||
chmod 755 $(DESTDIR)$(PREFIX)/bin/st
|
||||
chmod 755 $(DESTDIR)$(PREFIX)/bin/st-url
|
||||
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
|
||||
sed "s/VERSION/$(VERSION)/g" < st.1 > $(DESTDIR)$(MANPREFIX)/man1/st.1
|
||||
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/st.1
|
||||
|
|
|
@ -191,8 +191,9 @@ static MouseShortcut mshortcuts[] = {
|
|||
#define MODKEY ControlMask
|
||||
#define SHTKEY (ControlMask|ShiftMask)
|
||||
|
||||
static char *openurlcmd[] = { "/bin/sh", "-c", "st-url -o", "externalpipe", NULL };
|
||||
static char *copyurlcmd[] = { "/bin/sh", "-c", "st-url -c", "externalpipe", NULL };
|
||||
//static char *openurlcmd[] = { "/bin/sh", "-c", "st-url -o", "externalpipe", NULL };
|
||||
static char *openurlcmd[] = {"/bin/sh", "-c", "xurls | dmenu -c -l 20 -i | xargs -r $BROWSER",
|
||||
"externalpipe", NULL};
|
||||
|
||||
static Shortcut shortcuts[] = {
|
||||
/* mask keysym function argument */
|
||||
|
@ -203,7 +204,6 @@ static Shortcut shortcuts[] = {
|
|||
{ SHTKEY, XK_V, clippaste, {.i = 0} },
|
||||
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
|
||||
{ MODKEY, XK_o, externalpipe, {.v = openurlcmd } },
|
||||
{ SHTKEY, XK_O, externalpipe, {.v = copyurlcmd } },
|
||||
{ MODKEY, XK_k, kscrollup, {.i = 1} },
|
||||
{ MODKEY, XK_j, kscrolldown, {.i = 1} },
|
||||
};
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
urlregex="(((http|https|gopher|gemini|ftp|ftps|git)://|www\\.)[a-zA-Z0-9.]*[:]?[a-zA-Z0-9.,/:@$&%?$\#=_~-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)"
|
||||
|
||||
urls="$(sed 's/.*│//g' | tr -d '\n' | # First remove linebreaks and mutt sidebars:
|
||||
grep -aEo "$urlregex" | # grep only urls as defined above.
|
||||
uniq | # Ignore neighboring duplicates.
|
||||
sed "s/\(\.\|,\|;\|\!\\|\?\)$//;
|
||||
s/^www./http:\/\/www\./")" # xdg-open will not detect url without http
|
||||
|
||||
[ -z "$urls" ] && exit 1
|
||||
|
||||
while getopts "hoc" o; do case "${o}" in
|
||||
h) printf "Optional arguments for custom use:\\n -c: copy\\n -o: xdg-open\\n -h: Show this message\\n" && exit 1 ;;
|
||||
o) chosen="$(echo "$urls" | dmenu -c -l 20 -i)"
|
||||
setsid xdg-open "$chosen" >/dev/null 2>&1 & ;;
|
||||
c) echo "$urls" | dmenu -c -l 20 -i| tr -d '\n' | xsel -l /dev/null ;;
|
||||
*) printf "Invalid option: -%s\\n" "$OPTARG" && exit 1 ;;
|
||||
esac done
|
Loading…
Add table
Add a link
Reference in a new issue