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


Click here to return to the 'Higher/Higher/etc.' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Higher/Higher/etc.
Authored by: loren_ryter on Jan 20, '02 07:06:33PM

I'm neither a UNIX wonk nor do I know a lot about renice... But if my memory is correct that the range is -20 (highest priority) to 20 (lowest priority), this makes the script a bit more user-friendly:

------

property priorities : {"Highest (-20)", "Higher (-15)", "High (-10)", "Normal (0)", "Low (10)", "Lower (15)", "Lowest (20)"}
tell application "Finder" to set theApps to name of every process
activate
set theApp to (choose from list theApps OK button name "Edit Priority") as string
log theApp
if theApp is not false then
set thePID to do shell script "ps -axww | /usr/bin/grep '[/]" & theApp & "'| awk '{print $1}' | head -1"
set the_priority to (choose from list priorities OK button name "Set Priority") as string

if the_priority contains "Highest" then set newPriority to "-20"
if the_priority contains "Higher" then set newPriority to "-15"
if the_priority contains "High (" then set newPriority to "-10"
if the_priority contains "Normal" then set newPriority to "0"
if the_priority contains "Low (" then set newPriority to "10"
if the_priority contains "Lower" then set newPriority to "15"
if the_priority contains "Lowest" then set newPriority to "20"

log newPriority
Renice(newPriority, thePID, theApp)
end if
on Renice(newPriority, thePID, theApp)
try
set theConfirmation to (do shell script "renice " & newPriority & " -p " & thePID)
on error
set theConfirmation to (do shell script "renice " & newPriority & " -p " & thePID with administrator privileges)
end try
display dialog ("Changed priority of '" & (theApp as string) & "':" & return & theConfirmation) buttons {"OK"} giving up after 5
end Renice



[ Reply to This | # ]