HOWTO: Have Multiple Users Share an iTunes Library on One Machine

I recently purchased a new MacBook (never having owned a Mac before), and have been reading up on keeping things secure. Per one of those security-related suggestions, once everything was set up to my liking, I stopped using the admin account for everyday use and started forcing myself to log in as a regular user. I’ve also created a user account for my live-in girlfriend so she can go wild customizing her desktop with pictures of flowers, Hugh Jackman, Hugh Jackman laying in a bed of flowers, and so on, without making my eyes bleed.

The trouble is, we both buy music from iTunes on a regular basis using our own individual Apple ID accounts, and there isn’t an easy way to share our music seamlessly with one another. We have similar tastes in music and we’d like it so that when one person buys a new song, it is immediately available for the other person to listen to. Ideally, we’d also be able to create our own unique playlists and assign ratings to the various songs to reflect our own personal likes/dislikes. This article lays out the details of how I accomplished that goal…

The Problem

The main problem with assigning two iTunes Libraries to the same location comes down to permissions. By default, when you download music through iTunes, it assigns permissions based on the user that’s logged in. It only allows that user and people in the UNIX group “wheel” to read the music file (if you’re UNIX-literate, that means it has 640 file permissions). Since a different user (in this case, my girlfriend) would not fit into those categories, she doesn’t have the proper permissions to read any of the music I download. To put it simply…music needs to be world readable.

The Solution

These permissions can be easily fixed by running a simple script that uses the chmod command to modify your music so anyone can play it. To give you a breakdown, the script runs a few safety checks to ensure that you have the proper permissions to modify the files, it then checks that your specified library actually exists, and then it recursively looks at all of your music making sure it is world readable.

The trick is getting the script to run only when necessary as not to waste resources. You could set up a cron job, but then it would have to run on a fixed time table. Either it would run more often than necessary, or not often enough…so cron is out. You could set up a launchd/launchctl configuration file and specify it to run when your Library folder is modified, but unfortunately that doesn’t get triggered when a sub-folder gets modified…so launchd is out.

The key ends up being something called a “LoginHook” that is configured in the /etc/ttys file. Creating a LoginHook will ensure that whenever any user logs in to the machine, the script will be run and proper permissions will be set on the entire library.

Putting it All Together

This should go without saying, but I’m saying it…back up all of your music files before doing anything else! Once that’s done, proceed with the following steps:

  1. First you must pick a centralized location that all your users have access to and make sure the directory exists. I picked /Users/Shared/Music/iTunes and created it on the command-line using:
    mkdir -p /Users/Shared/Music/iTunes
  2. Next, you must adjust your iTunes settings to point to the new location. You do this by launching iTunes, then navigate to iTunes » Preferences… » Advanced, and under the General tab, click the Change… button next to the “iTunes Music folder location” box. Navigate to your newly-created centralized folder (in my case /Users/Shared/Music/iTunes), and click Choose.
  3. For ease of maintenance and to prevent duplicate files from being generated, make sure the checkbox labeled “Copy files to iTunes Music folder when adding to library” is not selected (this is also under the Advanced section of the Preferences dialog box).
  4. Click OK to accept the changes you made to your preferences.
  5. To copy your current library to the new location, navigate to Advanced » Consolidate Library… then proceed by clicking Consolidate. This step only needs to be performed one time per user to ensure that everything gets moved over to the new location.
  6. Repeat these configuration steps for all users that you wish to consolidate libraries for.

At this point, you’ve done all that is necessary to do within iTunes, and all that is left is fixing the file permissions. To do that, log in as a user with administrator privileges and follow these steps:

  1. Download the script and put it anywhere you want. I made another directory called /Users/Shared/bin/ and put the script there, but the location doesn’t really matter.
  2. Modify the script’s LIBRARY variable (in the CONSTANTS section) to point to the centralized music directory you created above.
  3. Ensure that the script is executable by running:
    chmod 755 /Users/Shared/bin/share-itunes
  4. Then edit the /etc/ttys file with your favorite text editor, and change the line starting with “console” to add:
    -LoginHook /Users/Shared/bin/share-itunes
    right after the “loginwindow” declaration. Make sure you actually point it to the location where you downloaded the script to. The line should have looked something like this before you edited it:

    console "/System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow" vt100 on secure onoption="/usr/libexec/getty std.9600"

    …and look like this after you edit it:

    console "/System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow -LoginHook /Users/Shared/bin/share-itunes" vt100 on secure onoption="/usr/libexec/getty std.9600"
  5. Save the file, and close your text editor.

That’s it! Everything should be all set to go and your permissions will be checked each time you log in to the computer.

Caveats

The only thing I wasn’t able to automate was adding new music purchased by my girlfriend in to my library so it actually shows up when I launch iTunes. For all I know, there may be an easy way to automate it, but I haven’t found one at this time. Luckily it’s a fast/easy procedure to do by hand…

To actually have new music purchased by another user show up in your library, all you have to do is launch iTunes, go to File » Add to Library…, then navigate to your shared music folder and click Choose. It will take a few seconds to parse through your library, but after it’s done, all of the music should be available for you to play. You will have to do that every time you know that music has been added by another user, but everything else should be automated for you.

Why it Works

Unless you get tricky, iTunes always stores your album artwork, playlists, and song rating information in a file under your home directory (well, in ~/Music/iTunes, to be precise). It also stores a meta file with information regarding what it thinks should be included in your library. These files will be unique to the user even if you choose to share your actual music collections. So when you update your iTunes preferences to move the location of your Library, you still retain the ability to have all your own custom settings regardless of what other users add to the common music folder.

By periodically telling iTunes to add the common music directory in to your library, you’re simply forcing it to update the library meta file so it reflects whatever actually exists in that directory…regardless of whether or not you were the person to purchase the music.

Hopefully these steps will be able to help someone else out there having a similar issue. When I first started looking in to how to accomplish this configuration, I though surely it would be easy and done before, but alas, things got a bit more complicated than I had hoped. If you know of a better way, please do leave a comment and let us know what works for you. If you have any trouble understanding these procedures or getting it to work, let me know and I’ll see what I can do to help out…happy listening!

New Flat-Panel Displays using Ceramics

While waiting for my tax refund, I’ve been checking out flat panel TVs and I ran across this article on a new ceramic flat panel technology in Popular Science:

“Researcher Steve Yando has invented a ceramic panel that converts video signals into moving pictures. Yando did not have to invent a new way to convert electricity into light; flat electroluminescent panels to do that have been on the market for years. The problem was scanning: how to switch individual points of the panel on and off very rapidly to build up the quick-changing light-and-dark pattern of the TV image. …Yando solved the problem by pulling a very cute trick with piezoelectric crystals, which are old and long-used electric devices.

Piezo crystals convert mechanical movement to electricity, or electricity to mechanical movement; they work either way….Yando’s trick was to make a piezo crystal work both ways at the same time — convert electricity to motion, the motion to electricity — and combine that with an electroluminescent panel to get light.

Ceramic Panel Diagram

The dinner-plate picture panel is a flat rectangle of piezo ceramic (lead zirconate-titanate) coated with electroluminescent phosphor (a powder similar to fluorescent-lamp coating). Electrodes at the sides of the ceramic bring scanning voltages that determine which point will light up. Electrodes on the back and face of the panel bring TV picture-signal voltages that determine how bright the point will light up. (The face electrode has to be transparent so you can see the picture that is created.)

The scanning voltage causes a mechanical vibration to move across the ceramic in a line - like a long ocean wave. The vibration wave, in turn, generates a piezo voltage in the ceramic. So a line of voltage moves across the panel. But suppose you feed in two scanning voltages simultaneously, one to the top edge of the panel and one to a side edge. This gives you two moving lines of vibration waves and two moving lines of piezo voltage. Where the lines cross, you get a moving point of double piezo voltage. You can control the course of this point - make it scan across the panel - by doing things with the circuits in the TV receiver.

The electroluminescent layer will light up whenever there is a voltage. But you don’t want the moving lines to show at all, and even the moving spot must adjust it’s brightness to suit the TV picture signal. So a varying resistance cuts out all voltage at or below the double-strength piezo voltage - even the moving spot, unaided, won’t light up. But the additional voltage supplied by the picture signal can make the moving spot glow, changing it from dim to bright to create the entire image.”

Though the article is a little old and lacking on display specifications, they did mention that a full-scale prototype has already been built. So I may end up waiting another year or so to see if this develops before looking for a new TV.

If anybody has any more info on ceramic flat panel TV technology, please drop me a line at aaron [at] elasticdog dot com.

Update

Whew…talk about an April Fools Day-spurred adrenaline rush! I think we duped literally TENS of people with that one (not much response from Digg, Fark, or Shacknews). This entry was the brain-child of my diabolical work friend James whom found this article in a 1961 version of Popular Science. Here are scans of the original article: page one and page two. Hopefully next year we can get more traffic coming our way if we want to pull a successful prank on the internets. Live and learn…

Upgrade in Progress

I’m currently in the middle of upgrading my WordPress installation to 1.5.1.3, and thus things might not be working quite right around here for a bit. I’m not dead, and I will be going back to my original design once I can take to time to develop a theme properly. With all all of the hacking I did to the default installation of WordPress 1.2.1, it could be a little while. Bear with me…thanks

WordPress Design Sandbox

When creating a website, it’s best not to make experimental changes to your code directly on your server for the whole world to see. What if you accidentally mess things up beyond all recognition and don’t remember exactly what you did? It’s a good idea to test developmental changes in a protected environment where you know they won’t effect anything that’s mission critical. Typically this is simple to do as you can just edit the files on your local machine before uploading them. Making a test bed for WordPress, however, is a bit more difficult due to the nature of dynamic page generation.

WordPress uses PHP to pull data from a database, and then subsequently creates the needed HTML based off of that data. Without the PHP, your page would merely render as junk. Thus, in order to see a design change made in your CSS, you’re usually forced to upload the file to your server so WordPress has access to its heart and soul. Not anymore…

The Sandbox

In an effort to make things easier on WordPress users wanting to customize the default installation, I’ve created a static version of the default WP template and have placed it in a zip file along with a clean copy of wp-layout.css and print.css. The template includes a sample entry that utilizes many common HTML elements so you can tell exactly what they would look like on your page.

In this developmental sandbox, you can make structural code changes, try out new CSS techniques, whatever you want…all without having to worry about messing up your live site. Once you get things the way you like them, simply update your real files accordingly, and you’re good to go!

Installation

  1. Download wp-design-sandbox.zip
  2. Create a new directory on your local machine in which you’d like to place the test files
  3. Unzip the three files into the newly created directory
  4. Design away