diff options
Diffstat (limited to 'opener')
-rwxr-xr-x | opener | 27 |
1 files changed, 22 insertions, 5 deletions
@@ -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 |