--- moz-0.2.1 Thu Nov 28 03:18:14 2002 +++ moz-0.2.2a Sat Nov 30 06:04:56 2002 @@ -1,7 +1,7 @@ #!/bin/sh echo # ---------------------------------------------------------------------------- -echo "moz 0.2.1 -- Starts a new Mozilla process or accesses a URI in a running one" +echo -e "\033[1mmoz 0.2.2a -- Starts a new Mozilla process or accesses a URI in a running one\033[m" echo "Copyright (c) 2002 Thomas Lahn " # # This program is free software; you can redistribute it and/or modify @@ -18,40 +18,62 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# This is work in progress. Feel free to report any bugs. +# This is work in progress. +# Send suggestions and bug reports to # # ChangeLog # ========== # +# 0.2.2 (2002-11-29) +# ------------------ +# * Accessing the URI in a new browser tab (Mozilla 1.0.1, 1.1 and beyond). +# * Mixing of new-window, new-tab and new-process options. +# * Cosmetics: +# - Added status messages +# - Bold-formatted title +# # 0.2.1 (2002-11-28) # ------------------- -# * Allow more than one URI -# * Allow termination/killing of a running Mozilla process +# * More than one URI +# * Termination/killing of a running Mozilla process # -# 0.2.0 (2002-11-04) -# ------------------- -# * First public release (GPL) +# See the ChangeLog text file for further information. # # ---------------------------------------------------------------------------- function help { - echo "Usage: moz [ ( -t | -k ) ] [ ( -n | -? ) ] [URI] [...]" echo -# version 0.2.2 proposal -# echo "-b, --block Block the shell for the \`mozilla' process, i.e. prevent" + echo "Usage: `basename $0` [ ( --term | --kill | -? ) ]" + echo " [ ( -w | -t ) ] [URI] [...] [ ( -w | -t ) ] [...]" + echo +# version 0.2.3 proposal +# echo " --block Block the shell for the \`mozilla' process, i.e. prevent" # echo " following commands to be executed until Mozilla is quit." - echo "-t, --term Terminate all Mozilla processes (first)." - echo "-k, --kill Kill all Mozilla processes (first)." - echo "-n, --new Show the resource specified by URI in a new browser window." - echo " If not provided, the current resource will be replaced." - echo " Resources with \`mailto:' URIs will create a new e-mail" - echo " compose window anyway." + echo " --term Terminate all Mozilla processes (first). Note that the" + echo " -t option now refers to the creation of a new browser tab" + echo " for POSIX conformance. See below." + echo "-k, --kill Kill all Mozilla processes (first). Note that -k (but not" + echo " --kill) will become obsolete in future versions for" + echo " POSIX conformance." + echo "-n, --new Same as -w. This may become obsolete in future versions." + echo "-w, --win Show the resource(s) specified by URI in a new browser window." + echo " If not provided, the current window/tab content will be" + echo " replaced. Resources with \`mailto:' URIs will create a" + echo " new e-mail compose window anyway." + echo "-t, --tab Show the resource(s) specified by URI in a new browser tab." + echo " Works with Mozilla 1.0.1, 1.1 and beyond." + echo " If not provided, the current window/tab content will be" + echo " replaced. Resources with \`mailto:' URIs will create a" + echo " new e-mail compose window anyway." echo "-?, --help Show this help screen." echo "URI The URI(s) of the resource(s) to display. If not provided," echo " the configured home page is displayed. Two or more URIs" echo " are separated by spaces, while the second and following" echo " resources are displayed in a new browser window (if not" - echo " a \`mailto:' URI)." + echo " specified otherwise with -t or a \`mailto:' URI)." + echo " Use \`-' NOT to (re)start Mozilla or access another URI." + echo " Useful with --term or --kill." + echo } rc_done="\033[1mdone\033[m" @@ -75,7 +97,7 @@ function KillMoz { if [ -n "`ps -A | grep mozilla-bin`" ]; then - echo -n "sending all Mozilla processes the " + echo -n "Sending all Mozilla processes the " case "$1" in "-9") echo -n "KILL";; *) echo -n "TERM";; @@ -88,25 +110,33 @@ else msg_done fi - else - echo -e "No Mozilla process is running that could be terminated or killed.\n" + else + echo -e "No Mozilla process is running that could be terminated or killed." fi } echo "Protected under the terms of the GNU General Public License (GPL)." echo "See COPYING file or http://www.fsf.org/copyleft/gpl.html for details." -echo "This is work in progress. Feel free to report any bugs." +help=0 +if [ -z "$1" ] || [ "$1" = "-?" ] || [ "$1" = "--help" ]; then + help=1; + help +fi +echo "Send suggestions and bug reports to " echo +test $help -eq 1 && exit 255 if [ "$1" = "-?" ] || [ "$1" = "--help" ]; then help else + kill=0 # check for term/kill - if [ "$1" = "--term" ] || [ "$1" = "-t" ] || [ "$1" = "--kill" ] || [ "$1" = "-k" ]; then + if [ "$1" = "--term" ] || [ "$1" = "--kill" ] || [ "$1" = "-k" ]; then + kill=1 if [ "$1" = "--kill" ] || [ "$1" = "-k" ]; then sig=-9; fi KillMoz $sig shift - test -z "$*" && exit 0 + test -z "$1" && echo && exit 0 fi # check for Mozilla @@ -117,14 +147,25 @@ exit 255 fi + # block=0 # check for block mode # if [ "$1" = "-b" ] || [ "$1" = "--block" ]; then block=1; shift; fi - # check for new-window - new_win=0 - if [ "$1" = "-n" ] || [ "$1" = "--new" ]; then new_win=1; shift; fi - while [ -n "$1" ]; do + # check for new-window + new_win=0 + if [ "$1" = "-n" ] || [ "$1" = "--new" ] || [ "$1" = "-w" ] || [ "$1" = "--win" ]; then + new_win=1 + shift + fi + + # check for new-tab + new_tab=0 + if [ "$1" = "-t" ] || [ "$1" = "--tab" ]; then new_tab=1; shift; fi + + # check for disable new-* + test "$1" = "-" && shift && test -z "$1" && echo && exit 0 + # check if the current user has Mozilla already run chk=`ps -u $(whoami) | grep mozilla-bin` if [ -z "$chk" ]; then @@ -140,6 +181,7 @@ # check what kind of URI was given cmd="openURL($1" test $new_win -eq 1 && cmd=$cmd", new-window" + test $new_tab -eq 1 && cmd=$cmd", new-tab" cmd=$cmd")" # checking for grep chk=`which grep 2> /dev/null` @@ -158,10 +200,17 @@ cmd="mailto($address)" fi fi - echo -n "Accessing URI '$1'" + echo -n "Accessing URI " + if [ -n "$1" ]; then + echo -n "'$1'" + else + echo -n "'about:blank'" + fi test $new_win -eq 1 -a $mailto=0 && echo -n " in a new browser window" - echo "..." + test $new_tab -eq 1 -a $mailto=0 && echo -n " in a new browser tab" + echo -n "... " mozilla -remote "$cmd" & + if [ $? -eq 0 ]; then msg_done; else msg_failed; fi fi shift new_win=1