Merge branch '4479_console_players'

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
This commit is contained in:
Yury V. Zaytsev 2024-09-18 18:28:43 +02:00
commit 9e06a50eb8
10 changed files with 52 additions and 47 deletions

View File

@ -25,9 +25,9 @@ staroffice_console() {
}
get_ooffice_executable() {
if which loffice >/dev/null 2>&1; then
if command -v loffice >/dev/null 2>&1; then
echo "loffice"
elif which ooffice >/dev/null 2>&1; then
elif command -v ooffice >/dev/null 2>&1; then
echo "ooffice"
else
echo -n
@ -52,35 +52,35 @@ do_view_action() {
fi
;;
msdoc)
if which wvHtml >/dev/null 2>&1; then
if command -v wvHtml >/dev/null 2>&1; then
tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX`
wvHtml "${MC_EXT_FILENAME}" --targetdir="$tmp" page.html
elinks -dump "$tmp/page.html"
rm -rf "$tmp"
elif which antiword >/dev/null 2>&1; then
elif command -v antiword >/dev/null 2>&1; then
antiword -t "${MC_EXT_FILENAME}"
elif which catdoc >/dev/null 2>&1; then
elif command -v catdoc >/dev/null 2>&1; then
catdoc -w "${MC_EXT_FILENAME}"
elif which word2x >/dev/null 2>&1; then
elif command -v word2x >/dev/null 2>&1; then
word2x -f text "${MC_EXT_FILENAME}" -
else
strings "${MC_EXT_FILENAME}"
fi
;;
msxls)
if which xlhtml >/dev/null 2>&1; then
if command -v xlhtml >/dev/null 2>&1; then
tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX`
xlhtml -a "${MC_EXT_FILENAME}" > "$tmp/page.html"
elinks -dump "$tmp/page.html"
rm -rf "$tmp"
elif which xls2csv >/dev/null 2>&1; then
elif command -v xls2csv >/dev/null 2>&1; then
xls2csv "${MC_EXT_FILENAME}"
else
strings "${MC_EXT_FILENAME}"
fi
;;
dvi)
which dvi2tty >/dev/null 2>&1 && \
command -v dvi2tty >/dev/null 2>&1 && \
dvi2tty "${MC_EXT_FILENAME}" || \
catdvi "${MC_EXT_FILENAME}"
;;

View File

@ -6,7 +6,9 @@
action=$1
filetype=$2
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
if [ -n "$DISPLAY" ]; then
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
fi
do_view_action() {
filetype=$1
@ -16,13 +18,13 @@ do_view_action() {
[ -n "$DISPLAY" ] && sxpm "${MC_EXT_FILENAME}"
;;
*)
if which exif >/dev/null 2>&1; then
if command -v exif >/dev/null 2>&1; then
exif "${MC_EXT_FILENAME}" 2>/dev/null
E=$?
else
E=1
fi
if [ $E != 0 ] && which exiftool >/dev/null 2>&1; then
if [ $E != 0 ] && command -v exiftool >/dev/null 2>&1; then
exiftool "${MC_EXT_FILENAME}" 2>/dev/null
fi
identify "${MC_EXT_FILENAME}"
@ -45,15 +47,21 @@ do_open_action() {
;;
*)
if [ -n "$DISPLAY" ]; then
if which geeqie >/dev/null 2>&1; then
if command -v geeqie >/dev/null 2>&1; then
(geeqie "${MC_EXT_FILENAME}" &)
else
(gqview "${MC_EXT_FILENAME}" &)
fi
elif which see >/dev/null 2>&1; then
# no backgrounding for console viewers
elif command -v fim >/dev/null 2>&1; then
fim "${MC_EXT_FILENAME}"
elif command -v fbi >/dev/null 2>&1; then
fbi "${MC_EXT_FILENAME}"
elif command -v zgv >/dev/null 2>&1; then
zgv "${MC_EXT_FILENAME}"
# run-mailcap as a last resort
elif command -v see >/dev/null 2>&1; then
(see "${MC_EXT_FILENAME}" &)
else
(zgv "${MC_EXT_FILENAME}" &)
fi
;;
esac

View File

@ -13,7 +13,7 @@ do_view_action() {
case "${filetype}" in
iso9660)
if which isoinfo > /dev/null 2>&1; then
if command -v isoinfo >/dev/null 2>&1; then
isoinfo -d -i "${MC_EXT_FILENAME}" && isoinfo -l -R -J -i "${MC_EXT_FILENAME}"
else
7za l "${MC_EXT_FILENAME}"
@ -74,7 +74,7 @@ do_open_action() {
sqlite3 "${MC_EXT_FILENAME}"
;;
glade)
if which glade-3 >/dev/null 2>&1; then
if command -v glade-3 >/dev/null 2>&1; then
(glade-3 "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
else
(glade-2 "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)

View File

@ -6,7 +6,9 @@
action=$1
filetype=$2
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
if [ -n "$DISPLAY" ]; then
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
fi
do_view_action() {
filetype=$1

View File

@ -129,7 +129,7 @@ do_open_action() {
;;
chm)
if [ -n "$DISPLAY" ]; then
which kchmviewer > /dev/null 2>&1 \
command -v kchmviewer >/dev/null 2>&1 \
&& (kchmviewer "${MC_EXT_FILENAME}" &) \
|| (xchm "${MC_EXT_FILENAME}" &)
else

View File

@ -6,17 +6,19 @@
action=$1
filetype=$2
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
if [ -n "$DISPLAY" ]; then
[ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open"
fi
do_view_action() {
filetype=$1
case "${filetype}" in
*)
if which mplayer >/dev/null 2>&1; then
if command -v mplayer >/dev/null 2>&1; then
mplayer -identify -vo null -ao null -frames 0 "${MC_EXT_FILENAME}" 2>&1 | \
sed -n 's/^ID_//p'
elif which mpv_identify.sh >/dev/null 2>&1; then
elif command -v mpv_identify.sh >/dev/null 2>&1; then
mpv_identify.sh "${MC_EXT_FILENAME}"
else
echo "Please install either mplayer or mpv to get information for this file"
@ -28,24 +30,17 @@ do_view_action() {
do_open_action() {
filetype=$1
if which mpv >/dev/null 2>&1; then
PLAYER=mpv
elif which mplayer >/dev/null 2>&1; then
PLAYER=mplayer
if command -v mpv >/dev/null 2>&1; then
PLAYER="mpv --really-quiet"
else
echo "Please install either mplayer or mpv to play this file"
return
PLAYER="mplayer -really-quiet"
fi
case "${filetype}" in
*)
if [ -n "$DISPLAY" ]; then
($PLAYER "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
else
$PLAYER -vo null "${MC_EXT_FILENAME}"
fi
;;
esac
if [ -n "$DISPLAY" ]; then
($PLAYER "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
else
$PLAYER -vo null "${MC_EXT_FILENAME}"
fi
}
case "${action}" in

View File

@ -32,7 +32,7 @@
#*** file scope functions **********************************************
XORRISO=$(which xorriso 2>/dev/null)
XORRISO=$(command -v xorriso >/dev/null 2>&1)
# This snippet is used to undo xorriso's Text_shellsafe(). Pseudocode for the
# function:
@ -144,7 +144,7 @@ xorriso_rm() {
# tested to comply with isoinfo 2.0's output
test_iso () {
ISOINFO=$(which isoinfo 2>/dev/null)
ISOINFO=$(command -v isoinfo >/dev/null 2>&1)
if test -z "$ISOINFO"; then
echo "isoinfo not found" >&2
return 1

View File

@ -17,10 +17,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
P7ZIP=`which 7z 2>/dev/null` \
|| P7ZIP=`which 7zz 2>/dev/null` \
|| P7ZIP=`which 7za 2>/dev/null` \
|| P7ZIP=`which 7zr 2>/dev/null` \
P7ZIP=`command -v 7z >/dev/null 2>&1` \
|| P7ZIP=`command -v 7zz >/dev/null 2>&1` \
|| P7ZIP=`command -v 7za >/dev/null 2>&1` \
|| P7ZIP=`command -v 7zr >/dev/null 2>&1` \
|| P7ZIP=""
# Let the test framework hook in:

View File

@ -16,7 +16,7 @@
RAR=rar
# Prefer unrar (freeware).
UNRAR=`which unrar 2>/dev/null`
UNRAR=`command -v unrar >/dev/null 2>&1`
[ -z $UNRAR ] && UNRAR=$RAR
[ ! -x $UNRAR -a -x $RAR ] && UNRAR=$RAR

View File

@ -10,8 +10,8 @@
# On Debian/Ubuntu wimtools can be installed via:
# apt install wimtools
which wimlib-imagex 2>/dev/null > /dev/null || exit 1
WIM=`which wimlib-imagex`
command -v wimlib-imagex >/dev/null 2>&1 || exit 1
WIM=`command -v wimlib-imagex >/dev/null 2>&1`
AWK=@AWK@
[ -n "$2" ] || exit 1