O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  


 
Buy the book!
iPod and iTunes Hacks
By Hadley Stern
October 2004
More Info

HACK
#66
Alter the iTunes Look and Feel by Resource Hacking
Alter iTunes's resource file to change the way the iTunes interface looks.
[Discuss (0) | Link to this hack]

All applications use computer code to describe how they look. With a little work, you can get to the code that makes iTunes looks the way it looks and alter it to your heart's content. This method isn't as simple as "Skin iTunes with ShapeShifter" . However, your efforts will be rewarded, because you will be able to change elements of the iTunes UI that ShapeShifter cannot touch.

Figure 1. Activating your theme in the ShapeShifter System Preferences panel

For this hack, we'll open up the iTunes resource file and change the code of hex values to adjust the appearance of the iTunes GUI. In order to open and edit the resource file, you need HexEdit (http://hexedit.sourceforge.net; free).

A typical Mac OS X application is not a single executable file but rather a bundle of files that contain their own executable binaries to make things tick. Apple hides all this from us, so that all we see is one tidy iTunes icon. However, with a little hacking, we can get to an application's executable binaries.

To find the executable file we want to hack, first open iTunes' package contents. Make sure iTunes is closed and Control-click on the iTunes application icon in the Finder. A contextual menu will pop up. Select Show Package Contents, and you will see a list of files usually kept hidden from you, as shown in .

Figure 2. iTunes package contents

The file we are interested in is a Unix executable file, /Applications/iTunes/ Mac OS/iTunes. Because this file is the code behind iTunes, if we mess anything up, iTunes won't open, so go ahead and make a backup copy (Option-drag) to your desktop. That way, if anything goes awry, you can simply copy it back and, Bob's your uncle, it'll be good as new. When you launch HexEdit, you'll be taken directly to an open window. Navigate to the iTunes executable file and click the Open button. shows the open resource file. Within this file are the hexadecimal color codes that iTunes uses for its interface; find and change them, and you'll alter the colors of the elements in iTunes.

Figure 3. The code that makes iTunes tick

Before changing any colors, you'll need to figure out what you want them to be. Digital colors can be described in several ways: RGB (Red, Green, Blue), HSB (Hue, Saturation, Brightness), and, for the purpose of this hack, by hexadecimal values. The hexadecimal system is unique to describing color on the computer and is a base-16 number system. Don't worry; you don't need to know the ins and outs of hex colors to get this hack going (although it helps to have a little background so these strange numbers don't throw you off).

To determine which colors to use, open DigitalColor Meter, which is included with Mac OS X and is located at /Applications/Utilities/DigitalColor Meter. Using this tool, you can find out the color of any pixel on your screen. The iTunes executable file uses color in the 16-bit hexadecimal color format, which DigitalColor Meter can translate. Just select "RGB As Hex Value, 16-bit" from the pull-down menu.

Now, as you drag your mouse around your screen, you'll notice that DigitalColor Meter picks up and displays the color values of the individual pixels, as shown in .

Figure 4. DigitalColor Meter, picking up the hexadecimal values of any pixel on the screen

If you are just playing around with this hack, you can open a colorful web page and capture a color that interests you. You can lock in a particular color at any time by pressing &command;-L; DigitalColor Meter won't track new colors as you move your mouse about until you unlock it again with another &command;-L.

Once you've chosen your hexadecimal color code, it's time to paint iTunes with it by entering the code into the iTunes executable file you have open in HexEdit. Use the code references in to find the element you want to adjust.

WARNING

Make sure to read through the rest of the hack before you get started. Making changes willynilly will render your iTunes unworkable.

Table 4. Code references for elements to adjust in iTunes

Element

Code

Backgound

00375C10

Active levels

00375C20

Background of songs

003D4C00

Vertical bars that separate columns

003C4F30

Etched text colors

<p/>

Front

003BA338

Back

00410C84

Content frame colors

<p/>

Top

00410C32

Bottom

00410C34

Left

00410C3C

Right

00410C44

Inside

00410C2A

List colors

<p/>

White

00410C6C

Light sky

00410C64

Select

<p/>

Underline

00410C74

Select and inactive

00410C54

Underline

00410C7C

Separator (vertical)

<p/>

Select

003FEFA0

Select and inactive

003FEFA8

Text (Select)

003ED064

LCD level indicator colors

<p/>

Levels background

003B8E70

Inactive levels

003B8E68

Actual levels Top

003B8E60

Actual levels

003B8E58

Background

003B8E50

Window titles text colors

<p/>

Inactive

003BA340

For this example, let's change the background of the LCD in iTunes. The code we need to find is 003B8E50.

TIP

This is not the hex value of our new color; it's the line of code we need to find in the iTunes executable file.

Switch to HexEdit, go to Find → Go To Address, and enter 003B8E50, as shown in . Make sure to select Hex before clicking Go!

Figure 5. The Go To Address window in HexEdit

HexEdit takes you to the exact spot at which the address begins. You will notice that the starting point might be at the first line of code, or it might be in the middle. This doesn't matter; you need to start hacking at the place HexEdit puts the insertion point.

Now, we are ready to enter the hexadecimal value from DigitalColor Meter. If you just type in the numbers, however, the iTunes file will become corrupt. It is important to select each value, enter the new hex code, and then select the next value. Lather, rinse, and repeat. Here are the hex values from that we are going to use:

R (the Red channel): AE3F

G (the Green channel): 5FF7

B (the Blue channel): 74BD

Starting with the Red values, select the first chunk of code after the insertion point and type AE, as shown in . Move over to the right, select the next chunk of code, and enter AE again. Make sure to select the code before you change it!

Figure 6. Editing the hex values in HexEdit

Do the same for the other two channels, always repeating the value twice. Once you have finished, save the file and quit out of HexEdit. Start up iTunes and, if you did everything correctly, your changes will show up. So if you don't like the colors iTunes uses, with this hack, now you know how to change them!


O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.