a tiny webserver used to display the current itunes song
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 66 lines 2.7 kB view raw view rendered
1###eyetunes 2 3eyetunes is a system for displaying the current iTunes track information on 4a secondary monitor or other small window. It shows the track name (scrolling 5it when it's too long), artist, album, star rating, and album art. The entire 6window fades darker when iTunes is paused. 7 8It is optimized for an 800x600 resolution screen, like a MiMo USB monitor. 9 10[![](http://i.imgur.com/GgaidhN.jpg)](http://i.imgur.com/GgaidhN.jpg) 11 12####Usage 13 140. Install the `rb-appscript` gem. 15 16 `$ sudo gem install rb-appscript` 17 181. Run the `eyetunes.rb` script to start the web server. 19 20 `$ ruby eyetunes.rb &` 21 222. Start the GUI/browser with the specified geometry of your secondary display: 23 24 `$ ./eyetunesgui -x 1920 -y 0 -w 800 -h 600 &` 25 26####How it works 27 28eyetunes.rb is a Ruby script that uses the `rb-appscript` gem to talk to 29iTunes via AppleScript. It also runs a WEBrick web server on 127.0.0.1 30port 2000 where it serves a simple HTML page with some JavaScript. 31 32Pointing a web browser at `http://127.0.0.1:2000/` will load a basic black 33page and position the text labels that will hold the track information. An 34Ajax loop starts and polls back to the web server every 500 milliseconds, 35which retrieves the current track information from iTunes and displays it 36on the page. 37 38- If the track id is the same as what was passed by the browser, a null 39 response is returned so the browser doesn't have to do anything. 40 41- Otherwise, the current track, artist, and album name, with the album art and 42 rating are retrieved. Because iTunes sends back album art wrapped in a PICT 43file, the data blob has to be searched through to pull out the JPEG or PNG data 44that the browser can understand. That blob is base64-encoded and returned to 45the browser as a `data:` URI to avoid another round-trip to fetch a separate 46image. 47 48####Standalone browser 49 50While eyetunes will work in any standard web browser, displaying it on a 51separate monitor without any window chrome, in full-screen mode while not 52causing problems with other full-screen apps, is more complicated than it 53probably should be. 54 55Previous versions were using a [Fluid](http://fluidapp.com/) browser configured 56to load `http://127.0.0.1:2000/` in full-screen, but this required manually 57positioning the browser, adjusting the settings, and then having to re-do it if 58it ever failed to load the eyetunes page for some reason. Fluid also seems to 59be broken on OS X Mavericks. 60 61Now a standalone browser is included which creates a small Cocoa window with a 62WebKit frame hard-coded to load `http://127.0.0.1:2000/` at the specified screen 63geometry. 64 65To re-compile the browser, install XCode and execute `xcodebuild` in the `gui` 66directory.