[X-Unix] Hiding apps from the command line

Kirk McElhearn kirklists at wanadoo.fr
Fri Mar 26 07:19:31 PST 2004


On 3/26/04 4:08 PM, "Simon Forster" <simon-lists at ldml.com> wrote:

> The error seems to get thrown if the second command line arg is not
> given - whether it's needed or not.

I still get it, even if I add another argument.
> 
> FWIW, my take on the script:
> 
> 
> ---------START----------
> 
> #!/bin/sh
> # This script lets you hide a specified application, the Finder, all
> # applications but the Finder, or all applications other than a
> specified
> # application.
> # Syntax is as follows:
> #
> # hide -o [appname] - hides all other apps
> # hide -a           - hides all apps but Finder
> # hide -f           - hides Finder
> # hide -v [appname] - shows specified app
> # hide -t           - toggles shown apps

Nice idea!

> # hide -x           - shows terminal

Why? Since you're typing this from Terminal, it shouldn't matter.

As it was before, this is the behavior:

hides all apps but specified app; if no app is specified, Terminal remains
visible

> # hide [appname]       - hides specified app
> #
> # For applications whose names contain spaces, they must be quoted,
> # ie, hide "microsoft word".  This command is case-insensitive.
> 
> osascript <<END
> tell application "Finder"
> 
> if "$1" begins with "-" then
> if "$1" contains "o" then set visible of every process whose visible
> is true and name is not "$2" to false

I wonder if the "begins with" and "contains" is any better/faster than
simply "is -o" etc.?

> if "$1" contains "a" then set visible of every process whose visible
> is true and name is not "Finder" and name is not "$2" to false
> if "$1" contains "f" then set visible of process "Finder" to false
> if "$1" contains "v" then tell me to tell application "$2" to
> activate
> if "$1" contains "t" then
> set theVisible to name of every process whose visible is true
> repeat with theProcess in every process
> if theVisible contains name of theProcess then
> set visible of contents of theProcess to false
> else
> set visible of contents of theProcess to true
> end if
> end repeat
> end if
> if "$1" contains "x" then tell application "Terminal" to activate
> else if exists application process "$1" then
> set visible of application process "$1" to false

This part's not working for me...

> end if
> 
> end tell
> END
> 
> -----------END----------

 
 
Kirk
 
        My latest book: How to Do Everything with Mac OS X Panther
                  http://www.mcelhearn.com/htde.html
 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
 . . . . . . .  kirk at mcelhearn.com | http://www.mcelhearn.com  . . . . . .
 . .  Kirk McElhearn | Chemin de la Lauze | 05600 Guillestre | France  . .



More information about the X-Unix mailing list