Skip to content

Commit

Permalink
Merge branch '4479_console_players'
Browse files Browse the repository at this point in the history
Signed-off-by: Yury V. Zaytsev <[email protected]>
  • Loading branch information
zyv committed Sep 18, 2024
2 parents 84af354 + 50976ce commit 9e06a50
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 47 deletions.
18 changes: 9 additions & 9 deletions misc/ext.d/doc.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"
;;
Expand Down
22 changes: 15 additions & 7 deletions misc/ext.d/image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions misc/ext.d/misc.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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 &)
Expand Down
4 changes: 3 additions & 1 deletion misc/ext.d/sound.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion misc/ext.d/text.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 13 additions & 18 deletions misc/ext.d/video.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/vfs/extfs/helpers/iso9660.in
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/vfs/extfs/helpers/u7z
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/vfs/extfs/helpers/urar.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/vfs/extfs/helpers/uwim.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9e06a50

Please sign in to comment.