[X-Unix] Hiding apps from the command line
Simon Forster
simon-lists at ldml.com
Fri Mar 26 08:17:46 PST 2004
On 26 Mar 2004, at 16:12, Kirk McElhearn wrote:
> So how can we get it to work if two args are not supplied? That's a
> waste...
> It has something to do with the tell Finder bit.
I took your hint from a post a few mins ago:
------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
# hide -x - shows terminal
# 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
set arg1 to "$1"
set arg2 to "$2"
tell application "Finder"
if arg1 begins with "-" then
if arg1 contains "o" then set visible of every process whose visible
is true and name is not arg2 to false
if arg1 contains "a" then set visible of every process whose visible
is true and name is not "Finder" and name is not arg2 to false
if arg1 contains "f" then set visible of process "Finder" to false
if arg1 contains "v" then tell me to tell application arg2 to
activate
if arg1 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 arg1 contains "x" then tell application "Terminal" to activate
else if exists application process arg1 then
set visible of application process arg1 to false
end if
end tell
END
--------END-------
Seems to fix it on my system. Watch out for stray line breaks though.
Simon Forster
_____________________________________________________
LDML Ltd, 62 Pall Mall, London, SW1Y 5HZ, UK
Tel: +44 (0)70 9230 5244 Fax: +44 (0)70 9230 5247
_____________________________________________________
More information about the X-Unix
mailing list