diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-11-24 00:34:10 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-11-24 00:34:10 +0100 |
| commit | b227267cea3afa3a7e39bb24c20d500262f32c12 (patch) | |
| tree | 4a9f8b55d3bec0fba7a6da881c10416e2876450e /open-file | |
| parent | feeb30effb2f41b3fdc2f76c9e45869c9e601ed4 (diff) | |
| download | scripts-b227267cea3afa3a7e39bb24c20d500262f32c12.tar.gz scripts-b227267cea3afa3a7e39bb24c20d500262f32c12.zip | |
Some changes for new temrinal file management style
Diffstat (limited to '')
| -rwxr-xr-x | open-file | 34 |
1 files changed, 24 insertions, 10 deletions
| @@ -10,6 +10,15 @@ | |||
| 10 | 10 | ||
| 11 | menu=${MENU:-dmenu} | 11 | menu=${MENU:-dmenu} |
| 12 | 12 | ||
| 13 | video=${VIDEOPLAYER:-mpv} | ||
| 14 | music=${MUSICPLAYER:-mpv} | ||
| 15 | pdf=${VIEWER:-zathura} | ||
| 16 | img=${IMAGEVIEWER:-imv} | ||
| 17 | word=${TEXTDOCUMENT:-libreoffice} | ||
| 18 | sheet=${SPREADSHEET:-libreoffice} | ||
| 19 | html=${HTMLVIEWER:-firefox} | ||
| 20 | xedit=${XEDITOR:-gedit} | ||
| 21 | |||
| 13 | while getopts "s:t:" opt; do | 22 | while getopts "s:t:" opt; do |
| 14 | case "$opt" in | 23 | case "$opt" in |
| 15 | s) | 24 | s) |
| @@ -23,39 +32,44 @@ done | |||
| 23 | 32 | ||
| 24 | shift `expr $OPTIND - 1` | 33 | shift `expr $OPTIND - 1` |
| 25 | 34 | ||
| 26 | [ -z "$launcher" ] && launcher="spawn" | 35 | # If launcher = "", assume running in terminal, so some programs change |
| 36 | if [ -z "$launcher" ]; then | ||
| 37 | xedit=${EDITOR:-vi} | ||
| 38 | fi | ||
| 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 | ||
| 32 | case "$mimetype" in | 46 | case "$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" |
