Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'New scripts...' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
New scripts...
Authored by: robg on Jan 04, '08 05:54:09AM
An anonymous user submitted a new hint about freezing and thawing background apps, but it's basically a duplicate of this hint -- except for these two shell scripts to ease the process. The user's hint submission follows...

==================================================

I wrote two scripts to "freeze" and "thaw" programs. It works on most, feel free to tweak.

FREEZE script:
#!/bin/sh

if [ $# != 1 ]; then
echo "Enter a program name to freeze such as "iTunes""
exit
fi

arg=$1

command=`ps auxwww | grep "$arg" | grep "/Contents/MacOS/"`

if [ "$command" ] ; then
process=`ps auxwww | grep "$arg" | awk '/Contents/ {print $2}'`

osascript <<END
tell application "System Events"
set visible of process "$arg" to false
end tell
END

kill -STOP $process
echo "$arg has been frozen."
else
echo "No process matching this name."
exit
fi
THAW script:
#!/bin/sh

if [ $# != 1 ]; then
echo "Enter a program name to thaw that has been frozen."
exit
fi

arg=$1

command=`ps auxwww | grep "$arg" | grep "/Contents/MacOS/"`

#Check if program is running

if [ "$command" ] ; then
process=`ps auxwww | grep "$arg" | awk '/Contents/ {print $2}'`
kill -CONT $process
echo "$arg is continuting as normal."
else
echo "No process matching this name. I will attempt to open it."
open "/Applications/${arg}.app"
exit
fi
Now I can simply use these two scripts to quickly freeze and thaw any program I wish -- I made an Automator script to do this to five programs at once. For instance, freeze Safari and thaw Safari.

==================================================

I tested these scripts, and they work as expected.

-rob.

[ Reply to This | # ]