From 0c497ffde95ca98515ddeda591b6529a5025620d Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 27 Jul 2020 21:45:43 +0000 Subject: [PATCH] browser: make generic and remove redundant scripts --- bin/Makefile | 12 ++++++++---- bin/browser.sh | 20 ++++++++++++++++---- bin/riot-web-ui.sh | 15 --------------- bin/tor-browser.sh | 15 --------------- 4 files changed, 24 insertions(+), 38 deletions(-) delete mode 100644 bin/riot-web-ui.sh delete mode 100644 bin/tor-browser.sh diff --git a/bin/Makefile b/bin/Makefile index a7f6742..d44567c 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -15,9 +15,9 @@ PREFIX = $(HOME) MANPREFIX = $(PREFIX)/local BIN = ZZZ browser credentials fetch flac2ogg imgresize invidious \ - plumb pstsrv riot-web-ui rfcopen screenshot sekrit tor-browser \ - w3m-copy-link + plumb pstsrv rfcopen screenshot sekrit w3m-copy-link MAN1 = sekrit.1 +BROWSER_LINKS = tor-browser all: $(BIN) @@ -27,10 +27,14 @@ clean: install: all mkdir -p $(PREFIX)/bin cp -f $(BIN) $(PREFIX)/bin - cd $(PREFIX)/bin && chmod 555 $(BIN) + for t in $(BROWSER_LINKS); do \ + rm -f $(PREFIX)/bin/$$t; \ + ln $(PREFIX)/bin/browser $(PREFIX)/bin/$$t; \ + done + cd $(PREFIX)/bin && chmod 555 $(BIN) $(BROWSER_LINKS) mkdir -p $(MANPREFIX)/man/man1 cp -f $(MAN1) $(MANPREFIX)/man/man1 cd $(MANPREFIX)/man/man1 && chmod 444 $(MAN1) uninstall: - cd $(PREFIX)/bin && rm -f $(BIN) + cd $(PREFIX)/bin && rm -f $(BIN) $(BROWSER_LINKS) diff --git a/bin/browser.sh b/bin/browser.sh index 3868188..04ac6ba 100644 --- a/bin/browser.sh +++ b/bin/browser.sh @@ -1,6 +1,6 @@ #!/bin/sh # browser -# Written in 2019 by Lucas +# Written in 2019-2020 by Lucas # CC0 1.0 Universal/Public domain - No rights reserved # # To the extent possible under law, the author(s) have dedicated all @@ -10,6 +10,18 @@ # Dedication along with this software. If not, see # . -scp ~/.Xauthority _browser@localhost: -ssh -n _browser@localhost -- \ - env DISPLAY=${DISPLAY:-:0} /usr/local/bin/firefox "$@" +case ${0##*/} in +tor-browser) + user=_tor_browser + browser=/usr/local/bin/tor-browser + ;; +*) + user=_browser + browser=/usr/local/bin/firefox + ;; +esac + +dpy=${DISPLAY:-:0} +xauth extract - "$dpy" | + ssh -l "$user" localhost -- \ + xauth merge - '&&' env DISPLAY="$dpy" "$browser" "$@" diff --git a/bin/riot-web-ui.sh b/bin/riot-web-ui.sh deleted file mode 100644 index b647858..0000000 --- a/bin/riot-web-ui.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# browser -# Written in 2019 by Lucas -# CC0 1.0 Universal/Public domain - No rights reserved -# -# To the extent possible under law, the author(s) have dedicated all -# copyright and related and neighboring rights to this software to the -# public domain worldwide. This software is distributed without any -# warranty. You should have received a copy of the CC0 Public Domain -# Dedication along with this software. If not, see -# . - -scp ~/.Xauthority _riot_web_ui@localhost: -ssh -n _riot_web_ui@localhost -- \ - env DISPLAY=${DISPLAY:-:0} /usr/local/bin/firefox "$@" diff --git a/bin/tor-browser.sh b/bin/tor-browser.sh deleted file mode 100644 index 9de04eb..0000000 --- a/bin/tor-browser.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# tor-browser -# Written in 2019 by Lucas -# CC0 1.0 Universal/Public domain - No rights reserved -# -# To the extent possible under law, the author(s) have dedicated all -# copyright and related and neighboring rights to this software to the -# public domain worldwide. This software is distributed without any -# warranty. You should have received a copy of the CC0 Public Domain -# Dedication along with this software. If not, see -# . - -scp ~/.Xauthority _browser@localhost: -ssh -n _browser@localhost -- \ - env DISPLAY=${DISPLAY:-:0} /usr/local/bin/tor-browser "$@"