st

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit baa9fa076a4e334e04532b218a925b0a8e367a8c
parent d9f3fd8a16705e5adcb491234a076f6b94dfe4f5
Author: Luke Smith <luke@lukesmith.xyz>
Date:   Wed, 15 Apr 2020 16:43:14 -0400

following links now separate script

this avoids the effects of swallow in dwm

it also will not produce dmenu without found urls

Diffstat:
MMakefile | 3+++
Mconfig.h | 4+---
Ast-urlhandler | 15+++++++++++++++
3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile @@ -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 @@ -221,9 +221,7 @@ MouseKey mkeys[] = { { Button5, TERMMOD, zoom, {.f = -1} }, }; -static char *openurlcmd[] = { "/bin/sh", "-c", - "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' | dmenu -w $(xdotool getactivewindow) -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", "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' | dmenu -w $(xdotool getactivewindow) -i -p 'Copy which url?' -l 10 | tr -d '\n' | xclip -selection clipboard", diff --git a/st-urlhandler 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 -w "$(xdotool getactivewindow)" -i -p 'Follow which url?' -l 10)" + +setsid xdg-open "$chosen" >/dev/null 2>&1 &