Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Piplodocus

macrumors 6502a
Original poster
Apr 2, 2008
501
497
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!
 

krasnoyarsk

macrumors newbie
Feb 7, 2012
11
0
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
-----------
 

Piplodocus

macrumors 6502a
Original poster
Apr 2, 2008
501
497
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!
 

krasnoyarsk

macrumors newbie
Feb 7, 2012
11
0
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
-----------
 

Piplodocus

macrumors 6502a
Original poster
Apr 2, 2008
501
497
No joy. :confused: "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"?
 

Piplodocus

macrumors 6502a
Original poster
Apr 2, 2008
501
497
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!
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.