Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > OS X

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 29, 2012, 01:31 PM   #1
Piplodocus
macrumors regular
 
Join Date: Apr 2008
How do I "Nice/Renice" something on startup?

Hello!

If you're aware, you can use the "renice" command in terminal (or a 3rd party app) to increase the system priority of an app. Or you can start it up from the terminal using the nice command AFAIK.

Is there an easy way to make an app start up like that? Can I make the equivalent of a DOS batch file (yeah, I'm old skool PC) so I can run an icon to open the app already "nice"ed? Or a one-click applescript job or something similar?

BTW This is to increase the priority of my music app, Ableton Live, to about say -12 to guarantee less likelihood of dropouts etc when I have other apps open. Currently I do it with a 3rd party app, but it's a little tiresome opening the other app, scrolling to find it, and then choosing it, and setting the value every time. I might be imagining it, but this DOES seem to help. Could be imagining it, but an occasional odd rare dropout can ruin an finally otherwise perfect take!
__________________
17" Mid-2010 2.66GHz i7 MBP, 8GB RAM, 256GB Crucial M4 SSD + 5400rpm 1TB HDD (in MCE optibay), FW400/USB2.0 external Freecom DVD-RW, MOTU 828mk3. PC with iTunes/iCloud set-up. C2D Hackintosh. iPhone 5
Piplodocus is offline   0 Reply With Quote
Old Jul 2, 2012, 08:13 AM   #2
krasnoyarsk
macrumors newbie
 
Join Date: Feb 2012
You can use an applescript script with the "do shell script" command.
The real problem would be to find the unix id of Ableton (you'll need it to 'nice' the process), because this id number changes every startup.

So you would need to first ask System Events to find the unix id of Ableton , and then nice it.

Here is a script with these commands. Save it as an application, choose it as a auto login item and make sure it run at least 10 seconds AFTER Ableton Live. (BTW, I don't know what the name of the process is - if not "Ableton", find the correct one, for example with Activity Monitor, and edit the following script)
-----------
tell application "System Events"
set FrontAppId to (get unix id of every process whose name is "Ableton")
end tell
do shell script "renice -12 " & FrontAppId & " > /dev/null 2>&1 &" password "your passw" with administrator privileges
-----------
krasnoyarsk is offline   0 Reply With Quote
Old Jul 3, 2012, 01:17 PM   #3
Piplodocus
Thread Starter
macrumors regular
 
Join Date: Apr 2008
Ah, splendid! You can open it using nice rather than renice though can't you, so you don't then need the PID?

It's called "Live", so something like?...
------------------------------

do shell script "nice -12 Live > /dev/null 2>&1 &" password "your passw" with administrator privileges

------------------------------

Would that work? If I can click to open it already "nice"ed it would save me a click and an extra thing pinned in my dock too!

----------

P.S. By "on startup", I mean on starting Ableton Live, rather than on system startup.

Thanks!
__________________
17" Mid-2010 2.66GHz i7 MBP, 8GB RAM, 256GB Crucial M4 SSD + 5400rpm 1TB HDD (in MCE optibay), FW400/USB2.0 external Freecom DVD-RW, MOTU 828mk3. PC with iTunes/iCloud set-up. C2D Hackintosh. iPhone 5
Piplodocus is offline   0 Reply With Quote
Old Jul 3, 2012, 03:58 PM   #4
krasnoyarsk
macrumors newbie
 
Join Date: Feb 2012
Do not use 'nice', use 'renice'
What extra thing in the Dock? You mean the applescript? If so, just do this:
when saving the script as an app, make sure the option "Stay Open" in NOT checked. Your script will then quit itself, after renicing Live.

You can also run this script when launching Live. For that, You have to add a line to launch Live, and then wait a few seconds, and then the main part of the script can be run.
-----------
tell the Finder to open application "Ableton Live"
wait 10 seconds
tell application "System Events"
set FrontAppId to (get unix id of every process whose name is "Live")
end tell
do shell script "renice -12 " & FrontAppId & " > /dev/null 2>&1 &" password "your passw" with administrator privileges
-----------
krasnoyarsk is offline   0 Reply With Quote
Old Jul 3, 2012, 06:19 PM   #5
Piplodocus
Thread Starter
macrumors regular
 
Join Date: Apr 2008
No joy. "Wait" didn't work so I googled it. Used delay instead. It tried to open Live in the dock, and it bounced a couple of times, but then says...

error "Ableton Live 8 got an error: Can’t continue open." number -1708

---------- my revised script: ----------

open application "Ableton Live 8"
delay 10
tell application "System Events"
set FrontAppId to (get unix id of every process whose name is "Live")
end tell
do shell script "renice -12 " & FrontAppId & " > /dev/null 2>&1 &" password "xxxxxxxx" with administrator privileges

------------------------------------------

I assume I'm supposed to replace xxxxxxxx in the above with my actual password? I saved it as an "application" too. I assume that was right, and not save it as a "script"?
__________________
17" Mid-2010 2.66GHz i7 MBP, 8GB RAM, 256GB Crucial M4 SSD + 5400rpm 1TB HDD (in MCE optibay), FW400/USB2.0 external Freecom DVD-RW, MOTU 828mk3. PC with iTunes/iCloud set-up. C2D Hackintosh. iPhone 5
Piplodocus is offline   0 Reply With Quote
Old Jul 4, 2012, 07:38 PM   #6
Piplodocus
Thread Starter
macrumors regular
 
Join Date: Apr 2008
Seem to have done it. Thanks for the pointers...

-----------------(still includes bug fixing messages, commented out with "--")-------------

launch application "Ableton Live 8"
delay 10
-- display dialog "Waited!" buttons {"OK"} default button 1
tell application "System Events"
set FrontAppId to (get unix id of every process whose name is "Live")
end tell

do shell script "renice -8 " & FrontAppId password "My_PW_here!" with administrator privileges

-- display dialog "Reniced PID " & FrontAppId & " to -8 (hopefully)" buttons {"OK"} default button 1

----------

P.S. When I tried "renice -12 ..." it kept coming out as -1, but I figured -8 should be good enough to see if it makes any discernible difference!!!

I'm inspired to write a load of other useful scripts too now!
__________________
17" Mid-2010 2.66GHz i7 MBP, 8GB RAM, 256GB Crucial M4 SSD + 5400rpm 1TB HDD (in MCE optibay), FW400/USB2.0 external Freecom DVD-RW, MOTU 828mk3. PC with iTunes/iCloud set-up. C2D Hackintosh. iPhone 5

Last edited by Piplodocus; Jul 4, 2012 at 07:49 PM.
Piplodocus is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > OS X

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 08:28 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC