1
1
This commit makes a few improvements in default bindings:

 * use chm_http text-mode handler for CHM files;
 * play sounds only from videos in text mode;
 * use pdftotext -layout -nopgbrk switches;
 * try to use elinks before links for HTML;
 * soffice2html text-mode handler for SXW files;
 * wvHtml text-mode handler for doc files;
 * xlhtml text-mode handler for XLS files;
 * ppthtml text-mode handler for PPT/PPS files;
 * open=view+pager fallback (noX) for PostScript, PDF, OD[PST] and DVI;
 * standarized $DISPLAY checks.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Этот коммит содержится в:
Slava Zanko 2012-05-18 18:42:26 +03:00
родитель ff096a3e3a
Коммит ce07bec728
7 изменённых файлов: 109 добавлений и 20 удалений

Просмотреть файл

@ -7,6 +7,22 @@ action=$1
filetype=$2
STAROFFICE_REGEXP='\.(sxw|sdw|stw|sxc|stc|sxi|sti|sxd|std||sxm||sxg)$'
staroffice_console() {
filename=$1;shift
is_view=$1; shift
if [ -n "${is_view}" ]; then
is_view='-dump'
fi
tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX`
cd $tmp
soffice2html.pl "${filename}"
elinks ${is_view} content.html
rm -rf "$tmp"
}
do_view_action() {
filetype=$1
@ -15,19 +31,36 @@ do_view_action() {
ps2ascii "${MC_EXT_FILENAME}"
;;
pdf)
pdftotext "${MC_EXT_FILENAME}" -
pdftotext -layout -nopgbrk "${MC_EXT_FILENAME}" -
;;
odt)
odt2txt "${MC_EXT_FILENAME}"
if [ ` echo "${MC_EXT_FILENAME}" | grep -c "${STAROFFICE_REGEXP}"` -ne 0 ]; then
staroffice_console "${MC_EXT_FILENAME}" "view"
else
odt2txt "${MC_EXT_FILENAME}"
fi
;;
msdoc)
antiword -t "${MC_EXT_FILENAME}" || \
which wvHtml >/dev/null 2>&1 &&
{
tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX`
wvHtml "${MC_EXT_FILENAME}" --targetdir="$tmp" page.html
elinks -dump "$tmp/page.html"
rm -rf "$tmp"
} || \
antiword -t "${MC_EXT_FILENAME}" || \
catdoc -w "${MC_EXT_FILENAME}" || \
word2x -f text "${MC_EXT_FILENAME}" - || \
strings "${MC_EXT_FILENAME}"
;;
msxls)
xls2csv "${MC_EXT_FILENAME}" || \
which xlHtml >/dev/null 2>&1 && {
tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX`
xlhtml -a "${MC_EXT_FILENAME}" > "$tmp/page.html"
elinks -dump "$tmp/page.html"
rm -rf "$tmp"
} || \
xls2csv "${MC_EXT_FILENAME}" || \
strings "${MC_EXT_FILENAME}"
;;
dvi)
@ -46,31 +79,72 @@ do_open_action() {
case "${filetype}" in
ps)
(gv "${MC_EXT_FILENAME}" &)
if [ -n "$DISPLAY" ]; then
(gv "${MC_EXT_FILENAME}" &)
else
ps2ascii "${MC_EXT_FILENAME}" | ${PAGER:-more}
fi
;;
pdf)
(xpdf "${MC_EXT_FILENAME}" &)
if [ -n "$DISPLAY" ]; then
(xpdf "${MC_EXT_FILENAME}" &)
else
pdftotext -layout -nopgbrk "${MC_EXT_FILENAME}" - | ${PAGER:-more}
fi
#(acroread "${MC_EXT_FILENAME}" &)
#(ghostview "${MC_EXT_FILENAME}" &)
;;
ooffice)
(ooffice "${MC_EXT_FILENAME}" &)
if [ -n "$DISPLAY" ]; then
(ooffice "${MC_EXT_FILENAME}" &)
else
if [ ` echo "${MC_EXT_FILENAME}" | grep -c "${STAROFFICE_REGEXP}"` -ne 0 ]; then
staroffice_console "${MC_EXT_FILENAME}"
else
odt2txt "${MC_EXT_FILENAME}" | ${PAGER:-more}
fi
fi
;;
abw)
(abiword "${MC_EXT_FILENAME}" &)
;;
msdoc)
(abiword "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
if [ -n "$DISPLAY" ]; then
(abiword "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
else
tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX`
wvHtml "${MC_EXT_FILENAME}" --targetdir="$tmp" page.html -1
elinks "$tmp/page.html"
rm -rf "$tmp"
fi
;;
msxls)
(gnumeric "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
if [ -n "$DISPLAY" ]; then
(gnumeric "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
else
tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX`
xlhtml -a "${MC_EXT_FILENAME}" > "$tmp/page.html"
elinks "$tmp/page.html"
rm -rf "$tmp"
fi
;;
msppt)
if [ -n "$DISPLAY" ]; then
(ooffice %f >/dev/null 2>&1 &)
else
tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX`
ppthtml %f > "$tmp/page.html"
elinks "$tmp/page.html"
rm -rf "$tmp"
fi
;;
framemaker)
fmclient -f "${MC_EXT_FILENAME}"
;;
dvi)
if [ x$DISPLAY = x ]; then
dvisvga "${MC_EXT_FILENAME}"
if [ -z "$DISPLAY" ]; then
dvisvga "${MC_EXT_FILENAME}" || \
dvi2tty "${MC_EXT_FILENAME}" | ${PAGER:-more}
else
(xdvi "${MC_EXT_FILENAME}" &)
fi

Просмотреть файл

@ -33,7 +33,7 @@ do_open_action() {
(gimp "${MC_EXT_FILENAME}" &)
;;
*)
if [ "$DISPLAY" = "" ]; then
if [ -z "$DISPLAY" ]; then
zgv "${MC_EXT_FILENAME}"
else
(gqview "${MC_EXT_FILENAME}" &)

Просмотреть файл

@ -32,7 +32,7 @@ do_open_action() {
case "${filetype}" in
common)
if [ "$DISPLAY" = "" ]; then
if [ -z "$DISPLAY" ]; then
play "${MC_EXT_FILENAME}"
else
(xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
@ -46,14 +46,14 @@ do_open_action() {
vplay -s 22 "${MC_EXT_FILENAME}"
;;
mp3)
if [ "$DISPLAY" = "" ]; then
if [ -z "$DISPLAY" ]; then
mpg123 "${MC_EXT_FILENAME}"
else
(xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
fi
;;
ogg)
if [ "$DISPLAY" = "" ]; then
if [ -z "$DISPLAY" ]; then
ogg123 "${MC_EXT_FILENAME}"
else
(xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)

Просмотреть файл

@ -112,7 +112,14 @@ do_open_action() {
esac | ${pager}
;;
chm)
which kchmviewer > /dev/null 2>&1 && (kchmviewer "${MC_EXT_FILENAME}" &) || (xchm "${MC_EXT_FILENAME}" &)
if [ -n "$DISPLAY" ]; then
which kchmviewer > /dev/null 2>&1 \
&& (kchmviewer "${MC_EXT_FILENAME}" &) \
|| (xchm "${MC_EXT_FILENAME}" &)
else
chm_http "${MC_EXT_FILENAME}" & elinks http://localhost:8080/index.html
kill -INT %1
fi
;;
*)
;;

Просмотреть файл

@ -25,7 +25,11 @@ do_open_action() {
(realplay "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
;;
*)
(mplayer "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
if [ -z "$DISPLAY" ]; then
mplayer -vo null "${MC_EXT_FILENAME}"
else
(mplayer "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
fi
#(gtv "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
#(xanim "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
;;

Просмотреть файл

@ -6,7 +6,6 @@
action=$1
filetype=$2
do_view_action() {
filetype=$1
@ -26,10 +25,11 @@ do_open_action() {
case "${filetype}" in
html)
(if test -n "@X11_WWW@" && test -n "$DISPLAY"; then
(if [ -n "@X11_WWW@" -a -n "$DISPLAY" ]; then
(@X11_WWW@ file://"${MC_EXT_CURRENTDIR}"/"${MC_EXT_BASENAME}" &) 1>&2
else
links "${MC_EXT_FILENAME}" || \
elinks "${MC_EXT_FILENAME}" || \
links "${MC_EXT_FILENAME}" || \
lynx -force_html "${MC_EXT_FILENAME}" || \
${PAGER:-more} "${MC_EXT_FILENAME}"
fi) 2>/dev/null

Просмотреть файл

@ -564,6 +564,10 @@ type/^Microsoft\ Excel
Open=@EXTHELPERSDIR@/doc.sh open msxls
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view msxls
regex/i/\.(ppt|pps)$
Open=@EXTHELPERSDIR@/doc.sh open msppt
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view msppt
# Use OpenOffice.org to open any MS Office documents
type/^Microsoft\ Office\ Document
Open=@EXTHELPERSDIR@/doc.sh open ooffice