Set a static nice value for an executable?

michaelsanford

Translator, Web Developer
For example, I want Mail.app ALWAYS to start with a nice value of 5.

How would I go about doing that, if it's possible at all (but this is linux, I'm sure it's possible :) )

Thanks!
 
To the best of my knowledge, no. Your best bet would be to create a shell script which runs your executable using nice. In the case of application packages, you can simply move the executable aside and put in its place that shell script. Here's what I used for Mail:

Code:
#!/bin/sh
nice -n +5 $0.bak $1

I had moved Mail to Mail.bak, saved this shell script as Mail, then ran 'ps -xO nice' to verify my success (irrelevant lines removed):

Code:
  PID NI  TT  STAT      TIME COMMAND
 1180  5  ??  SN     0:06.05 /Applications/Mail.app/Contents/MacOS/Mail.bak -psn_0_9043969
anarchie%

I can't guarantee that this will work for all programs, as some finicky ones (*cough* STARCRAFT *cough*) seem not to obey all kinds of guidelines. Note that I couldn't use ./Mail.bak because applications launched by the Finder (Launch Services actually) have their working dir at /. Also note that I included $1, to preserve LS's -psn_X_XXXXXXX argument. Someday I'll know what it really means.
 
I didn't. I renamed Mail.app/Contents/MacOS/Mail to Mail.app/Contents/MacOS/Mail.bak, so that I could have my own program at Mail.app/Contents/MacOS/Mail so that it runs when I double-click Mail.app. I suppose I could have altered the CFBundleExecutable key in its Info.plist instead. Works either way.
 
Back
Top