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 | *) |
---|
18 | if which mplayer >/dev/null 2>&1; then |
---|
19 | mplayer -identify -vo null -ao null -frames 0 "${MC_EXT_FILENAME}" 2>&1 | \ |
---|
20 | sed -n 's/^ID_//p' |
---|
21 | elif which mpv_identify.sh >/dev/null 2>&1; then |
---|
22 | mpv_identify.sh "${MC_EXT_FILENAME}" |
---|
23 | else |
---|
24 | echo "Please install either mplayer or mpv to get information for this file" |
---|
25 | fi |
---|
26 | ;; |
---|
27 | esac |
---|
28 | } |
---|
29 | |
---|
30 | do_open_action() { |
---|
31 | filetype=$1 |
---|
32 | |
---|
33 | if which mpv >/dev/null 2>&1; then |
---|
34 | PLAYER=mpv |
---|
35 | elif which gmplayer >/dev/null 2>&1; then |
---|
36 | PLAYER=gmplayer |
---|
37 | else |
---|
38 | echo "Please install either mplayer or mpv to play this file" |
---|
39 | return |
---|
40 | fi |
---|
41 | |
---|
42 | case "${filetype}" in |
---|
43 | *) |
---|
44 | if [ -n "$DISPLAY" ]; then |
---|
45 | ($PLAYER "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) |
---|
46 | else |
---|
47 | (clear && mplayer -really-quiet "${MC_EXT_FILENAME}") |
---|
48 | fi |
---|
49 | ;; |
---|
50 | esac |
---|
51 | } |
---|
52 | |
---|
53 | case "${action}" in |
---|
54 | view) |
---|
55 | do_view_action "${filetype}" |
---|
56 | ;; |
---|
57 | open) |
---|
58 | ("${MC_XDG_OPEN}" "${MC_EXT_FILENAME}" >/dev/null 2>&1) || \ |
---|
59 | do_open_action "${filetype}" |
---|
60 | ;; |
---|
61 | *) |
---|
62 | ;; |
---|
63 | esac |
---|