1 | #!/bin/sh |
---|
2 | |
---|
3 | # $1 - action |
---|
4 | # $2 - type of file |
---|
5 | |
---|
6 | action=$1 |
---|
7 | filetype=$2 |
---|
8 | |
---|
9 | if [ -n "$DISPLAY" ]; then |
---|
10 | [ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open" |
---|
11 | fi |
---|
12 | |
---|
13 | do_view_action() { |
---|
14 | filetype=$1 |
---|
15 | |
---|
16 | case "${filetype}" in |
---|
17 | xpm) |
---|
18 | [ -n "$DISPLAY" ] && sxpm "${MC_EXT_FILENAME}" |
---|
19 | ;; |
---|
20 | *) |
---|
21 | if which exif >/dev/null 2>&1; then |
---|
22 | exif "${MC_EXT_FILENAME}" 2>/dev/null |
---|
23 | E=$? |
---|
24 | else |
---|
25 | E=1 |
---|
26 | fi |
---|
27 | if [ $E != 0 ] && which exiftool >/dev/null 2>&1; then |
---|
28 | exiftool "${MC_EXT_FILENAME}" 2>/dev/null |
---|
29 | fi |
---|
30 | identify "${MC_EXT_FILENAME}" |
---|
31 | ;; |
---|
32 | esac |
---|
33 | } |
---|
34 | |
---|
35 | do_open_action() { |
---|
36 | filetype=$1 |
---|
37 | |
---|
38 | case "${filetype}" in |
---|
39 | xbm) |
---|
40 | (bitmap "${MC_EXT_FILENAME}" &) |
---|
41 | ;; |
---|
42 | xcf) |
---|
43 | (gimp "${MC_EXT_FILENAME}" &) |
---|
44 | ;; |
---|
45 | svg) |
---|
46 | (inkscape "${MC_EXT_FILENAME}" &) |
---|
47 | ;; |
---|
48 | *) |
---|
49 | if [ -n "$DISPLAY" ]; then |
---|
50 | if which geeqie >/dev/null 2>&1; then |
---|
51 | (geeqie "${MC_EXT_FILENAME}" &) |
---|
52 | else |
---|
53 | (gqview "${MC_EXT_FILENAME}" &) |
---|
54 | fi |
---|
55 | elif which fim >/dev/null 2>&1; then |
---|
56 | (fim "${MC_EXT_FILENAME}") |
---|
57 | elif which fbi >/dev/null 2>&1; then |
---|
58 | (fbi "${MC_EXT_FILENAME}") |
---|
59 | else |
---|
60 | echo "Please install either fim or fbi to view this file" && sleep 10 |
---|
61 | return |
---|
62 | |
---|
63 | fi |
---|
64 | ;; |
---|
65 | esac |
---|
66 | } |
---|
67 | |
---|
68 | case "${action}" in |
---|
69 | view) |
---|
70 | do_view_action "${filetype}" |
---|
71 | ;; |
---|
72 | open) |
---|
73 | ("${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" >/dev/null 2>&1) || \ |
---|
74 | do_open_action "${filetype}" |
---|
75 | ;; |
---|
76 | *) |
---|
77 | ;; |
---|
78 | esac |
---|