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

Making iTunes imports unnoticeable Apps
Normally when I import music into iTunes, the whole system gets rather sluggish which makes it very awkward to work with it the while.

While iTunes needs to be highly prioritized by the system during playback operations to allow for smooth sound performance without any dropouts, there is no need for this during "pure" import-only activity. So I wrote a little script that will reprioritize the iTunes app. While this may result in bad play performance (occasional dropouts -- very rare), this makes background import almost unnoticeable. The whole system runs as smoothly as normal, and the only thing you'll notice is the CD drive running continuously. Here's the script:
  #!/bin/sh
ps -ax | grep iTunes.app | grep -v grep
renice 20 -p `ps -ax | grep iTunes.app | grep -v grep | cut -c1-5`
Just put the commands above into a file in your ~/bin directory and chmod +x the file. Whenever you just want to do background import, start iTunes and run the script in Terminal window afterwards. You'll see output like:
  500  ??  S      0:01.90 /Applications/iTunes.app/Contents/MacOS/iTunes /Appli
500: old priority 0, new priority 20
To return iTunes back to original scheduling priority, just close the app and restart it.

I find myself running iTunes almost always at low priority because dropouts are very very rare (I use the "big buffers" setting).
    •    
  • Currently 2.60 / 5
  You rated: 1 / 5 (5 votes cast)
 
[5,933 views]  

Making iTunes imports unnoticeable | 7 comments | Create New Account
Click here to return to the 'Making iTunes imports unnoticeable' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
obligatory corrections & shortcuts
Authored by: mervTormel on Jan 13, '02 03:48:20PM

remaining true to the lazy programmer ethic, here are some shortcuts, and the obligatory correction for the above hint, lest you be confused:

first, to avoid the [ grep -v grep ] exclusion expression (running grep twice is a crime), use a bracketed character in the grep regexp; "[i]Tunes" -- the ps line for the grep command itself will not be selected since the string "iTunes" does not appear in it.

second, to avoid getting the iTuneshelper process, use the canonical form of the iTunes application, which should always look like this:

... /iTunes -psn_ ...

this will effectively give you the process you are looking for ...

% ps -axw | grep "[i]Tunes -p"
777 ?? RN 5:52.52 /Applications/iTunes.app/Contents/MacOS/iTunes /Applications/iTunes.app/Contents/MacOS/iTunes -psn_0_3407

the -w switch in the ps command is to wrap wide output to show you the full process context. it need not be in the final command.

then use awk to peel out the first column to get the process pid ...

% ps -axw | grep "[i]Tunes -p" | awk '{print $1}'
777

now, feed that to your renice command, but using priority 20, instead of 0, which is a noop.

renice 20 -p `ps -ax | grep "[i]Tunes -p" | awk '{print $1}'`


cheers



[ Reply to This | # ]
RE: corrections
Authored by: skyko on Jan 14, '02 04:11:41AM
It's just amaziong how much effort can be spend to optimize something that
  1. works
  2. just takes a split seconds even when not (yet) optimized
  3. is only run once
Compare that to the very useful tip to make it available in the script menu which spares opening a Terminal ... ;-)

[ Reply to This | # ]
RE: corrections
Authored by: TvE on Mar 28, '10 08:49:03AM

Well - it has one good side effect:
You'll learn to make better shell scripts (I was just reminded about the "grep [part]OfMySearchWord trick - Something I recently read about it in my O'Reilly BASH book

PS.: You are not FORCED to use the suggestions - it's voluntary (keep 'em coming!) ;-)



[ Reply to This | # ]
"Pure" import?
Authored by: stonefish on Jan 13, '02 08:25:54PM

What is "pure" import? Do you mean importing without playing the CD at the same time, or importing without doing anything else with iTunes at the same time?



[ Reply to This | # ]
pure import
Authored by: mervTormel on Jan 13, '02 11:43:03PM

---
What is "pure" import? Do you mean importing without playing the CD at the same time, or importing without doing anything else with iTunes at the same time?
---

i think by pure import, he meant any kind of iTunes "add to library".

in my experience, if i have sputnix'd a bunch of mp3's, and drag my download folder to the iTunes window, there is a considerable time that the iTunes app becomes unresponsive.

the rest of the system remains completely responsive, so i find little need for the priority fiddling, just go do something else during the import.



[ Reply to This | # ]
Use Script Menu
Authored by: nagani on Jan 13, '02 10:51:34PM
If you have installed Script Menu, you could also put your script in your ~/Library/Scripts folder, and launch it from the script menu...

(Always try and keep the hood closed over Unix...)

[ Reply to This | # ]

Use Script Menu
Authored by: nagani on Jan 13, '02 10:53:05PM
If you have installed Script Menu, you could also put your script in your ~/Library/Scripts folder, and launch it from the script menu...

(Always try and keep the hood closed over Unix...)

[ Reply to This | # ]