The default desktop manager at the NSCL Is KDE. One of the functions KDE supports is the creation of desktop shortcuts. A desktop short cut is an icon on the KDE desktop that, when clicked, runs a specified program or script. This can be used to provide a friendly environment for users of your software. For the NSCL DAQ, desktop short cuts are almost always shell scripts.
First some hints about developing KDE shortcuts.
Make no assumptions about the environment or working directory of your short cut script. In general the bash startup scripts will not be loaded for a desktop shortcut.
Test your script thoroughly interactively before attempting to attach it to a shortcut. In particular ensure that it will run correctly with the current working directory set to e.g. /. Test that it will run with an empty environment. You can use export -n to remove names from the environment.
When you first bind your script to a short cut, run it in a terminal that will remain after the script exits. In this way you can see any error messages that may have come out.
See the daqstart command. It can be a very effective way to run commands so that you know when and why they exit and for automatically logging errors.
Ok, lets create a desktop shortcut that starts the readout program. We can start with our earlier script:
#!/bin/bash
#
# godaq by convention is the guy that starts up the readout program.
# it just start ReadoutShell.tcl
. ~/.bashrc
ssh $DAQHOST killall -9 Readout
$DAQROOT/Scripts/ReadoutShell.tcl $DAQHOST ~/bin/Readout $EVENTHOST \
$(cat ~/.passwd)
ssh $DAQHOST killall -9 Readout
The first issue we see is that the bash system wide initialization script (/etc/profile) may not get run. This should be sourced prior to .bashrc
Next, in the absence of a terminal, we have no way to capture error output from the Readout GUI. Furthermore, we will not know if the ReadoutGui has died if it is a different window of the virtual desktop.
Correcting these deficiencies yields:
Example 4-14. Desktop Shortcut Script for the ReadoutGui/Readout:
#!/bin/bash
#
# godaq by convention is the guy that starts up the readout program.
# it just start ReadoutShell.tcl
. /etc/profile
. ~/.bashrc
ssh $DAQHOST killall -9 Readout
/usr/opt/daq/current/bin/daqstart --error=file:$HOME/rdoerror.log --output=file:$HOME/rdoerror.log \
-notify \
$DAQROOT/Scripts/ReadoutShell.tcl $DAQHOST ~/bin/Readout $EVENTHOST \
$(cat ~/.passwd)
ssh $DAQHOST killall -9 Readout
Now one final potential issue. In some cases, we need to specify more than just the name of the readout program. We may need to hand some switches or paramters to the readout program. For example, the production readout program has a command language based on Tcl, and includes the ability to provide a Tcl server. You may want to start a readout with this turned on and a startup script provided to setup the Tcl environment for your program. This can be done simply by providing a script as the Readout program. For example:
Example 4-15. Passing parameters and switches to Readout
First the godaq shell script:
#!/bin/bash
#
# godaq by convention is the guy that starts up the readout program.
# it just start ReadoutShell.tcl
. /etc/profile
. ~/.bashrc
ssh $DAQHOST killall -9 Readout
/usr/opt/daq/current/bin/daqstart --error=file:$HOME/rdoerror.log --output=file:$HOME/rdoerror.log \
-notify \
$DAQROOT/Scripts/ReadoutShell.tcl $DAQHOST ~/bin/StartReadout $EVENTHOST \
$(cat ~/.passwd)
ssh $DAQHOST killall -9 Readout
Note that the Readout program is specified as ~/bin/StartReadout. This is a shell script that contains:
#!/bin/bash
#
~/bin/Readout -port=1234 < ~/experiment/current/readoutConfiguration.tcl