#!/bin/bash # Launch anything (and maybe log it) # Author: Chris Rouch # Date: 1987-2004 # Copyright (c) Chris Rouch 2004 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # or see http://www.gnu.org/licenses/gpl.txt ############################################################################## function chknexec { # if it exists, exec it if [ -n "$(which $1 2>/dev/null)" ]; then # echo $* exec $* else exec $INFO -t "Can't locate $1" Bummer fi } function findone { # find the first good app from a list str= for app in $*; do if [ -n "$(which $app 2>/dev/null)" ]; then useapp=$app return else if [ -z "$str" ]; then str="$app" else str="$str, $app" fi fi done # if here then none of them exists exec $INFO -t "$str not found" Bummer } ###################################################################### # main program starts here FULLNAME="Chris Rouch" export FULLNAME DIALHOST=ball THISHOST=`hostname` export PERLLIB=$HOME/lib/perl VOLUME=1 DELAY=1 LD_LIBRARY_PATH=\ /usr/X11R6/lib:\ /usr/openwin/lib:\ /usr/lib/Real:\ /usr/lib export LD_LIBRARY_PATH # export MOZILLA_FIVE_HOME=/usr/lib/mozilla-1.0.1 LOGFILE=$HOME/logs/launch export LANG=C INFO="/usr/bin/pyinfo -b -q" DB=$HOME/.launchdb logging=1 # include any path settings if [ -f "$HOME/.path" ]; then . $HOME/.path fi # include the editing functions if [ -f "$HOME/.edrc" ]; then . $HOME/.edrc fi # override any variables for this machine if [ -f "$HOME/.launchrc" ]; then . $HOME/.launchrc fi export PATH if [ -z "$1" ]; then $INFO "Nothing to launch" exit 1 else case $1 in %*) exit 0; # this is a launch comment esac fi if [ "$1" == "--nolog" ]; then logging= shift fi program=$1 shift if [ -n "$logging" ]; then echo "`date +%Y:%m:%d:%H:%M`,$program,$*" >> $DB fi if [ -x "`which osd_cat 2>/dev/null`" ]; then echo "Launching $program $*" | osd_cat -c \#4ffffff -f -monotype-arial-medium-r-normal-*-*-360-*-*-p-*-koi8-ru -d 1 fi # this switch does all the work case $program in address) chknexec gnomecard ;; audio) chknexec xmms;; autolock) chknexec xscreensaver -lock-mode;; autorun) chknexec autorun -q -c /usr/bin/grip -t $HOME/scripts/roxcd -n /bin/true ;; background) chknexec wallpaperd -log $HOME/logs/bg $*;; bgcl) chknexec wallpaperer -now -dir $HOME/data/backgrounds $*;;# -p $HOME/data/bgprefs;; biff) chknexec $HOME/scripts/ybserver;; calendar) chknexec /usr/bin/ical -iconic;; calculator) chknexec xcalc;; camera) chknexec gphoto;; cash) $HOME/bin/xz -config $HOME/data/cash/xz-config -data $HOME/data/cash/xz-data ;; cdmount) sudo mount /mnt/cdrom;; cdumount) sudo umount /mnt/cdrom;; cdplay) grip ;; clipboard) chknexec xcb ;; clock) chknexec wmclock -shape -position +800+0;; colormap) chknexec xcmap ;; cursor) chknexec xsetroot -cursor $HOME/icons/bill.xbm $HOME/icons/bill.msk;; dial) if [ "$THISHOST" == "$DIALHOST" ] then chknexec sudo wvdial logic> $HOME/logs/dialup 2>&1 else chknexec ssh $DIALHOST $HOME/scripts/launch dial fi;; dialkill) if [ "$THISHOST" == "$DIALHOST" ] then sudo killdial rm -f $HOME/logs/dialup else chknexec ssh $DIALHOST $HOME/scripts/launch dialkill fi;; dialstatus) if [ "$THISHOST" == "$DIALHOST" ] then $HOME/scripts/dialstatus else chknexec ssh $DIALHOST $HOME/scripts/launch dialstatus fi;; editor) _editor $*;; exitsound) level=`amixer get PCM|grep "Front Right: Playback"| awk '{print $4}'` amixer set PCM $VOLUME >/dev/null aplay $HOME/sounds/exit.wav amixer set PCM $level >/dev/null ;; fetchmail) chknexec fetchmail -d 120 -a `cat $HOME/.mailservers` ;; filemanager) chknexec gentoo;; firefox) chknexec www -browser firefox;; fonts) chknexec gnome-font-properties;; galeon) chknexec www -browser galeon;; gimp) chknexec /usr/bin/gimp;; gimp2) chknexec /usr/bin/gimp-2.0;; gnutella) chknexec gtk-gnutella > $HOME/logs/gnutella 2>&1;; hifi) ssh southall -l audio DISPLAY=`hostname`:0 xmms;; id3) findone easytag yamt chknexec $useapp;; mail) export LC_COLLATE=en_US # chknexec evolution --no-splash chknexec sylpheed ;; konqueror) chknexec www -browser konqueror;; load) chknexec gkrellm;; exmhmail) export MM_CHARSET=iso-8859-1 export LANG=en_US export MHCONTEXT=$HOME/MHMail/.exmhcontext rm -f $MHCONTEXT chknexec exmh ;; man) chknexec tkman ;; mixer) findone gmix gnome-volume-control chknexec $useapp ;; modem) case $1 in "ascii") unset MINICOM xterm -cr red -sb -e /usr/bin/minicom ;; "gui") chknexec /usr/bin/X11/seyon ;; "connect") chknexec $HOME/scripts/eso -i -x;; "disconnect") chknexec $HOME/scripts/eso -k ;; esac ;; mozilla) chknexec www -browser mozilla;; mp3next) chknexec xmms-shell -e 'forward';; mp3play) chknexec xmms-shell -e 'play' ;; mp3stop) chknexec xmms-shell -e 'pause' ;; netscape) chknexec www -browser netscape;; nobiff) /bin/cp $HOME/icons/tbiff/blank.png /a/cr/.yabber.png;; opera) chknexec opera $* ;; paint) chknexec xpaint ;; powersave) sudo apm -S;; recorder) chknexec recorder $* ;; hifirecorder) ssh southall -l audio DISPLAY=`hostname`:0 recorder $* 2>/dev/null;; refresh) chknexec xrefresh;; scan) chknexec xsane ;; iscan) cd /a/scan chknexec iscan ;; screendump) chknexec xwd | xpr -dev ps | lp ;; spreadsheet) chknexec gnumeric ;; term) chknexec gnome-terminal $*;; mgterm) chknexec multi-gnome-terminal --start-factory-server --use-factory $*;; kterm) chknexec konsole $*;; startsound) level=`amixer get PCM|grep "Front Right: Playback"| awk '{print $4}'` amixer set PCM $VOLUME >/dev/null aplay $HOME/sounds/start.wav amixer set PCM $level >/dev/null ;; toolbox) findone gnomecc gnome-control-center chknexec $useapp;; tracker) chknexec tracker;; video) chknexec gmplayer ;; viewer) chknexec /usr/X11R6/bin/xv -geom +0+70 -cgeom +600+70 ;; www) chknexec www $* ;; wp) if [ -x /usr/bin/ooffice ]; then chknexec /usr/bin/ooffice else chknexec $HOME/OpenOffice/soffice fi ;; xscreensaver) chknexec xscreensaver $*;; xterm) if [ -x "/usr/openwin/bin/xterm" ]; then chknexec /usr/openwin/bin/xterm -cr red -sl 1000 -ls -sb $* else chknexec /usr/X11R6/bin/xterm -cr red -sl 1000 -ls -sb $* fi;; Cancel) exit 0 ;; *) chknexec $program $*;; esac if [ $? -ne 0 ] then $INFO -t "Launch of $program failed" Bummer fi ########################## END ############################################