aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xopen-file37
1 files changed, 20 insertions, 17 deletions
diff --git a/open-file b/open-file
index 2207a6f..1592c75 100755
--- a/open-file
+++ b/open-file
@@ -41,55 +41,58 @@ toopen=$@
41for f in $toopen; do 41for f in $toopen; do
42 [ ! -f "$f" ] && echo "$f: bad argument" && exit 1 42 [ ! -f "$f" ] && echo "$f: bad argument" && exit 1
43 [ -z "$mimetype" ] && mimetype="$(file --mime-type "$f" -bL)" 43 [ -z "$mimetype" ] && mimetype="$(file --mime-type "$f" -bL)"
44
45 prog=""
44 case "$mimetype" in 46 case "$mimetype" in
45 video/*) 47 video/*)
46 $launcher $video "$f" 48 prog="$video"
47 ;; 49 ;;
48 audio/*) 50 audio/*)
49 $launcher $music "$f" 51 prog="$music"
50 ;; 52 ;;
51 application/pdf | application/postscript | image/vnd.djvu) 53 application/pdf | application/postscript | image/vnd.djvu)
52 $launcher $pdf "$f" 54 prog="$pdf"
53 ;; 55 ;;
54 image/*) 56 image/*)
55 $launcher $img "$f" 57 prog="$img"
56 ;; 58 ;;
57 application/msword | \ 59 application/msword | \
58 application/vnd.oasis.opendocument.text | text/rtf | \ 60 application/vnd.oasis.opendocument.text | text/rtf | \
59 application/vnd.openxmlformats-officedocument.wordprocessingml.*) 61 application/vnd.openxmlformats-officedocument.wordprocessingml.*)
60 $launcher $word "$f" 62 prog="$word"
61 ;; 63 ;;
62 application/ms-excel | application/vnd.oasis.opendocument.spreadsheet | \ 64 application/ms-excel | application/vnd.oasis.opendocument.spreadsheet | \
63 text/rtf | application/vnd.openxmlformats-officedocument.spreadsheetml.*) 65 text/rtf | application/vnd.openxmlformats-officedocument.spreadsheetml.*)
64 $launcher $sheet "$f" 66 prog="$sheet"
65 ;; 67 ;;
66 text/html | text/enriched) 68 text/html | text/enriched)
67 $launcher $html "$f" 69 prog="$html"
68 ;; 70 ;;
69 text/*) 71 text/*)
70 $launcher $xedit "$f" 72 prog="$xedit"
71 ;; 73 ;;
72 application/zip) 74 application/zip)
73 unzip "$f" 75 prog="unzip"
74 ;; 76 ;;
75 application/x-rar-compressed) 77 application/x-rar-compressed)
76 unrar "$f" 78 prog="unrar"
77 ;; 79 ;;
78 application/x-archive | application/x-tar | \ 80 application/x-archive | application/x-tar | \
79 application/x-bzip2 | application/gzip | application/x-lzip | \ 81 application/x-bzip2 | application/gzip | application/x-lzip | \
80 application/x-lzma | application/x-xz | application/x-gtar) 82 application/x-lzma | application/x-xz | application/x-gtar)
81 tar -tavf "$f" 83 prog="tar -tavf"
82 ;; 84 ;;
83 application/java-archive) 85 application/java-archive)
84 java -jar "$f" 86 prog="java -jar"
85 ;; 87 ;;
86 *) 88 *)
87 prog=$(dmenu_path | $menu -p "How to open $f ?") 89 prog=$(dmenu_path | $menu -p "How to open $f ?")
88 if [ -n "$prog" ]; then
89 $launcher $prog "$f"
90 else
91 exit 1
92 fi
93 ;; 90 ;;
94 esac 91 esac
92
93 if [ -n "$prog" ]; then
94 $launcher $prog "$f" &
95 else
96 exit 1
97 fi
95done 98done

Generated with cgit - Back to sebastiano.tronto.net