aboutsummaryrefslogtreecommitdiff
path: root/open-file
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xopen-file34
1 files changed, 24 insertions, 10 deletions
diff --git a/open-file b/open-file
index 0e8e210..9a54446 100755
--- a/open-file
+++ b/open-file
@@ -10,6 +10,15 @@
10 10
11menu=${MENU:-dmenu} 11menu=${MENU:-dmenu}
12 12
13video=${VIDEOPLAYER:-mpv}
14music=${MUSICPLAYER:-mpv}
15pdf=${VIEWER:-zathura}
16img=${IMAGEVIEWER:-imv}
17word=${TEXTDOCUMENT:-libreoffice}
18sheet=${SPREADSHEET:-libreoffice}
19html=${HTMLVIEWER:-firefox}
20xedit=${XEDITOR:-gedit}
21
13while getopts "s:t:" opt; do 22while getopts "s:t:" opt; do
14 case "$opt" in 23 case "$opt" in
15 s) 24 s)
@@ -23,39 +32,44 @@ done
23 32
24shift `expr $OPTIND - 1` 33shift `expr $OPTIND - 1`
25 34
26[ -z "$launcher" ] && launcher="spawn" 35# If launcher = "", assume running in terminal, so some programs change
36if [ -z "$launcher" ]; then
37 xedit=${EDITOR:-vi}
38fi
39
40#[ -z "$launcher" ] && launcher="spawn"
27[ -z "$mimetype" ] && mimetype="$(file --mime-type "$1" -bL)" 41[ -z "$mimetype" ] && mimetype="$(file --mime-type "$1" -bL)"
28 42
29[ -d "$1" ] && $launcher $XFILEMANAGER "$1" && exit 0 43[ -d "$1" ] && echo "$1: is a directory" && exit 1
30[ ! -f "$1" ] && echo "$1: bad argument" && exit 1 44[ ! -f "$1" ] && echo "$1: bad argument" && exit 1
31 45
32case "$mimetype" in 46case "$mimetype" in
33 video/*) 47 video/*)
34 $launcher $VIDEOPLAYER "$1" 48 $launcher $video "$1"
35 ;; 49 ;;
36 audio/*) 50 audio/*)
37 $launcher $MUSICPLAYER "$1" 51 $launcher $music "$1"
38 ;; 52 ;;
39 application/pdf | application/postscript | image/vnd.djvu) 53 application/pdf | application/postscript | image/vnd.djvu)
40 $launcher $VIEWER "$1" 54 $launcher $pdf "$1"
41 ;; 55 ;;
42 image/*) 56 image/*)
43 $launcher $IMAGEVIEWER "$1" 57 $launcher $img "$1"
44 ;; 58 ;;
45 application/msword | \ 59 application/msword | \
46 application/vnd.oasis.opendocument.text | text/rtf | \ 60 application/vnd.oasis.opendocument.text | text/rtf | \
47 application/vnd.openxmlformats-officedocument.wordprocessingml.*) 61 application/vnd.openxmlformats-officedocument.wordprocessingml.*)
48 $launcher $TEXTDOCUMENT "$1" 62 $launcher $word "$1"
49 ;; 63 ;;
50 application/ms-excel | application/vnd.oasis.opendocument.spreadsheet | \ 64 application/ms-excel | application/vnd.oasis.opendocument.spreadsheet | \
51 text/rtf | application/vnd.openxmlformats-officedocument.spreadsheetml.*) 65 text/rtf | application/vnd.openxmlformats-officedocument.spreadsheetml.*)
52 $launcher $SPREADSHEET "$1" 66 $launcher $sheet "$1"
53 ;; 67 ;;
54 text/html | text/enriched) 68 text/html | text/enriched)
55 $launcher $HTMLVIEWER "$1" 69 $launcher $html "$1"
56 ;; 70 ;;
57 text/*) 71 text/*)
58 $launcher $XEDITOR "$1" 72 $launcher $xedit "$1"
59 ;; 73 ;;
60 application/zip) 74 application/zip)
61 unzip "$1" 75 unzip "$1"

Generated with cgit - Back to sebastiano.tronto.net