mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Add a new script, dtapp, used to locate and run various helper programs
This script is located in /usr/dt/bin/dtapp, and is then symlinked to various helpers that can be used in DT actions to run programs. The various helpers currently installed are: dtapp_vimage - view an image file, override with DTAPP_VIMAGE. Defaults to xv, display, and gimp, in that order. dtapp_vpdf - view a PDF file, override with DTAPP_VPDF. Defaults to okular, xpdf dtapp_vps - view a postscript file, override with DTAPP_VPS. Defaults to mgv, gv dtapp_vvideo - view a video file, override with DTAPP_VVIDEO. Defaults to vlc, ffplay. When a request is made to view one of these files, the list of viewers will be tried, in order, until one is found. If none are found, an error message will be displayed. Add overrides to your ~/.dtprofile file. We can add more dtapp commands and defaults for them as needed. This is in preparation for integrating Antonis Tsolomitis' extended actions and icon files, coming up in future commits.
This commit is contained in:
parent
050fd75e80
commit
5259022498
4 changed files with 257 additions and 1 deletions
|
@ -1750,3 +1750,42 @@ programs/localized/ja_JP.dt-eucJP/dtsr/jpn.knj
|
|||
{ default
|
||||
install_target = /usr/dt/infolib/etc/ja_JP.EUC-JP/dtsr/jpn.knj
|
||||
}
|
||||
#
|
||||
#>>-----------------------------
|
||||
#
|
||||
# dtapp entries
|
||||
#
|
||||
#<<-----------------------------
|
||||
#
|
||||
#
|
||||
programs/dtapp/dtapp
|
||||
{ default
|
||||
install_target = /usr/dt/bin/dtapp
|
||||
mode = 0555
|
||||
}
|
||||
# Now the dtapp symlinks
|
||||
./dtapp
|
||||
{ default
|
||||
install_target = /usr/dt/bin/dtapp_vimage
|
||||
type = sym_link
|
||||
}
|
||||
./dtapp
|
||||
{ default
|
||||
install_target = /usr/dt/bin/dtapp_vweb
|
||||
type = sym_link
|
||||
}
|
||||
./dtapp
|
||||
{ default
|
||||
install_target = /usr/dt/bin/dtapp_vpdf
|
||||
type = sym_link
|
||||
}
|
||||
./dtapp
|
||||
{ default
|
||||
install_target = /usr/dt/bin/dtapp_vps
|
||||
type = sym_link
|
||||
}
|
||||
./dtapp
|
||||
{ default
|
||||
install_target = /usr/dt/bin/dtapp_vvideo
|
||||
type = sym_link
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ XCOMM $XConsortium: Imakefile /main/17 1996/10/06 17:13:20 rws $
|
|||
#if UseNSGMLS
|
||||
NSGMLSDIR = nsgmls
|
||||
#endif
|
||||
EXTRADIRS = types localized tttypes $(NSGMLSDIR) util
|
||||
EXTRADIRS = types localized tttypes $(NSGMLSDIR) util dtapp
|
||||
|
||||
XCOMM some of these cannot be built on linux yet.
|
||||
XCOMM dtinfo
|
||||
|
|
13
cde/programs/dtapp/Imakefile
Normal file
13
cde/programs/dtapp/Imakefile
Normal file
|
@ -0,0 +1,13 @@
|
|||
XCOMM make dtapp fro dtapp.src
|
||||
#define PassCDebugFlags
|
||||
|
||||
AllTarget(dtapp)
|
||||
|
||||
LOCAL_CPP_DEFINES = -DCDE_INSTALLATION_TOP=$(CDE_INSTALLATION_TOP) \
|
||||
-DCDE_CONFIGURATION_TOP=$(CDE_CONFIGURATION_TOP) \
|
||||
-DCDE_LOGFILES_TOP=$(CDE_LOGFILES_TOP)
|
||||
|
||||
CppScriptTarget(dtapp,dtapp.src,$(LOCAL_CPP_DEFINES),)
|
||||
|
||||
depend::
|
||||
|
204
cde/programs/dtapp/dtapp.src
Executable file
204
cde/programs/dtapp/dtapp.src
Executable file
|
@ -0,0 +1,204 @@
|
|||
XCOMM!/bin/ksh
|
||||
XCOMM
|
||||
XCOMM dtapp - provide an interface for some useful applications.
|
||||
XCOMM
|
||||
XCOMM #############################################################
|
||||
XCOMM #set -x # uncomment for debugging
|
||||
XCOMM ###############################################################
|
||||
XCOMM Init
|
||||
|
||||
DTAPP="dtapp" # Identity crisis
|
||||
APPNAME="$(basename $0)" # the app to locate/run
|
||||
|
||||
XCOMM apps to look for, given an action (based on APPNAME - see MAIN)
|
||||
|
||||
XCOMM image viewing
|
||||
if [ -z "$DTAPP_VIMAGE" ]
|
||||
then
|
||||
VIMAGE="xv display gimp"
|
||||
else
|
||||
VIMAGE="$DTAPP_VIMAGE"
|
||||
fi
|
||||
|
||||
XCOMM video viewing
|
||||
if [ -z "$DTAPP_VVIDEO" ]
|
||||
then
|
||||
VVIDEO="mplayer vlc ffplay"
|
||||
else
|
||||
VVIDEO="$DTAPP_VVIDEO"
|
||||
fi
|
||||
|
||||
XCOMM web (html) viewing
|
||||
if [ -z "$DTAPP_VWEB" ]
|
||||
then
|
||||
VWEB="firefox chrome chromium-browser lynx"
|
||||
else
|
||||
VWEB="$DTAPP_VWEB"
|
||||
fi
|
||||
|
||||
XCOMM postscript viewing
|
||||
if [ -z "$DTAPP_VPS" ]
|
||||
then
|
||||
VPS="gv"
|
||||
else
|
||||
VPS="$DTAPP_VPS"
|
||||
fi
|
||||
|
||||
XCOMM PDF viewing
|
||||
if [ -z "$DTAPP_VPDF" ]
|
||||
then
|
||||
VPDF="okular xpdf"
|
||||
else
|
||||
VPDF="$DTAPP_VPDF"
|
||||
fi
|
||||
|
||||
XCOMM ##############################################################
|
||||
XCOMM ## Utility Functions
|
||||
|
||||
XCOMM ## Find the path of a program
|
||||
FindProg()
|
||||
{
|
||||
# FindProg "program"
|
||||
# - returns full path, or ""
|
||||
|
||||
whence $1
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
XCOMM ## Show an error message
|
||||
ErrorMsg()
|
||||
{
|
||||
# ErrorMsg "Title "Message" ["OK"]
|
||||
# use dterror.ds to display it...
|
||||
|
||||
if [ -z "$3" ]
|
||||
then # default to 'OK'
|
||||
OKM="OK"
|
||||
else
|
||||
OKM="$3"
|
||||
fi
|
||||
|
||||
CDE_INSTALLATION_TOP/bin/dterror.ds "$2" "$1" "$OKM"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
XCOMM ## do a simple command
|
||||
DoSimpleCmd()
|
||||
{
|
||||
# DoSimpleCmd "commands" args
|
||||
|
||||
didone=0
|
||||
cmds="$1"
|
||||
shift
|
||||
args="$*"
|
||||
|
||||
for i in $cmds
|
||||
do
|
||||
thecmd="$(FindProg $i)"
|
||||
|
||||
if [ ! -z "$thecmd" ]
|
||||
then # it's there
|
||||
$thecmd $*
|
||||
didone=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $didone -eq 0 ]
|
||||
then # couldn't find a viewer
|
||||
ErrorMsg "Helper not found" \
|
||||
"${DTAPP}: Could not find any of the following\ncommands for this file type:\n\n$cmds"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
XCOMM ###############################################################
|
||||
XCOMM ### Actions
|
||||
|
||||
XCOMM ## Web browsing
|
||||
DoWeb()
|
||||
{
|
||||
# DoWeb [[arg] ...]
|
||||
|
||||
didone=0
|
||||
url="$1"
|
||||
|
||||
for i in $VWEB
|
||||
do
|
||||
thecmd="$(FindProg $i)"
|
||||
|
||||
if [ ! -z "$thecmd" ]
|
||||
then # it's there
|
||||
|
||||
# We'll do special things for lynx,
|
||||
# else we'll just call whatever is available, and
|
||||
# hope it's X aware...
|
||||
|
||||
case $i in
|
||||
lynx)
|
||||
# start a dtterm
|
||||
CDE_INSTALLATION_TOP/bin/dtterm -e $thecmd $url
|
||||
didone=1
|
||||
;;
|
||||
*)
|
||||
# any others
|
||||
$thecmd $url
|
||||
didone=1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $didone -eq 1 ]
|
||||
then
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $didone -eq 0 ]
|
||||
then # couldn't find a viewer
|
||||
ErrorMsg "Helper not found" \
|
||||
"${DTAPP}: Could not find any of the following\nweb browsers:\n\n$VWEB"
|
||||
fi
|
||||
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
XCOMM ##################################################################
|
||||
XCOMM ## MAIN
|
||||
|
||||
XCOMM # We'll just look at our args and decide what to do...
|
||||
|
||||
XCOMM # Commands we'll recognize
|
||||
|
||||
COMMANDS="dtapp_vimage dtapp_vweb dtapp_vpdf dtapp_vps dtapp_vvideo"
|
||||
|
||||
case $APPNAME in
|
||||
dtapp_vimage)
|
||||
DoSimpleCmd "$VIMAGE" $*
|
||||
;;
|
||||
dtapp_vweb)
|
||||
DoWeb $*
|
||||
;;
|
||||
dtapp_vpdf)
|
||||
DoSimpleCmd "$VPDF" $*
|
||||
;;
|
||||
dtapp_vps)
|
||||
DoSimpleCmd "$VPS" $*
|
||||
;;
|
||||
dtapp_vvideo)
|
||||
DoSimpleCmd "$VVIDEO" $*
|
||||
;;
|
||||
*)
|
||||
# Unknown
|
||||
ErrorMsg "${DTAPP}: Unknown Helper Application" \
|
||||
"\"$APPNAME\" is not a recognized Helper Application. \nKnown Helper Applications are:\n\n$COMMANDS"
|
||||
;;
|
||||
esac
|
||||
|
||||
XCOMM # Fini
|
||||
exit 0
|
Loading…
Add table
Add a link
Reference in a new issue