summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2020-08-11 23:50:32 +0200
committerAki <please@ignore.pl>2020-08-11 23:50:32 +0200
commit5d31df6d7334845c286200f7430cdee13bc0d1d5 (patch)
treec975fe88fb03c0129458131f3c5edfeafb010f99
parent1946b8aee30fa7e16d49d72215849c9255dfc81b (diff)
downloadbrowse-5d31df6d7334845c286200f7430cdee13bc0d1d5.zip
browse-5d31df6d7334845c286200f7430cdee13bc0d1d5.tar.gz
browse-5d31df6d7334845c286200f7430cdee13bc0d1d5.tar.bz2
Changed browse and opener to support simple opening in the same view
-rwxr-xr-xbrowse9
-rwxr-xr-xopener27
2 files changed, 30 insertions, 6 deletions
diff --git a/browse b/browse
index 1135820..bdedbca 100755
--- a/browse
+++ b/browse
@@ -1,2 +1,9 @@
#!/bin/sh
-./phttp $@ | xargs ./opener
+while getopts f: opt; do
+ case $opt in
+ f) OPENER_ARGS="-f $OPTARG";;
+ \?) echo "Usage: $0 [-f view] url" >&2; exit 1;;
+ esac
+done
+shift `expr $OPTIND - 1`
+./phttp $@ | xargs ./opener $OPENER_ARGS
diff --git a/opener b/opener
index 6ece94e..06f0c52 100755
--- a/opener
+++ b/opener
@@ -1,8 +1,25 @@
#!/bin/sh
+while getopts f: opt; do
+ case $opt in
+ f) ORIGIN_VIEW=$OPTARG;;
+ \?) echo "Usage: $0 [-f view] mime_type base_address file" >&2; exit 1;;
+ esac
+done
+shift `expr $OPTIND - 1`
case "$1" in
- application/pdf) exec zathura "$3";;
- image/*) exec sxiv "$3";;
- text/html*) exec ./viewhtml "$3" "$2";;
- text/*) exec less "$3";;
- *) echo "\e[31m$1\e[0m $2 $3";;
+ application/pdf) VIEWER=zathura;;
+ image/*) VIEWER=sxiv;;
+ text/html*) VIEWER=./viewhtml;;
+ text/*) VIEWER=less;;
+ *) echo "\e[31m$1\e[0m $2 $3" >&2; exit 1;;
esac
+if [ $VIEWER = $ORIGIN_VIEW ]; then
+ echo $@
+ exit 0
+else
+ case $VIEWER in
+ zathura | sxiv | less) exec $VIEWER $3;;
+ \./*) exec $VIEWER $3 $2;;
+ esac
+fi
+exit 1