Zach Berry

Designer & Developer

Hacking Cog to have an iTunes style library

I use Cog on OS X as my primary music application which I'm pretty happy with - It's very lightweight and plays FLAC files. Still, I prefer how Rhythmbox and iTunes manages your music in one large library. Cog, on the other hand, gives you a directory listing and requires you to drag and drop files into a library to listen to them.

This post describes a way to make Cog work more like iTunes. The library for Cog is simply a m3u playlist file on the filesystem. I wrote a script that would overwrite the m3u file with list of files in my music directory whenever you run Cog. To do this:

  1. Rename the actual Cog application (within the /Applications/Cog.app folder). In the terminal,
mv /Applications/Cog.app/Contents/MacOS/Cog /Applications/Cog.app/Contents/MacOS/Cog-Application
  1. Create a shell script to masquerade as Cog. This will first update the Cog m3u file, then run Cog. Copy the script below in a file called 'Cog' and place it at /Applications/Cog.app/Contents/MacOS/
#!/bin/sh

######################  
#Update Library File:#  
######################  
LIBRARY_FILE=~/Library/Application\ Support/Cog/Default.m3u #Location of Cog playlist file (Shouldn't need to change this)  
LIBRARY_FOLDER=/Volumes/Music/collection/tagged/ #The folder that keeps all of the music you want to listen to

echo ' ' > $LIBRARY_FILE #Clear out library  
find $LIBRARY_FOLDER -type f -name "*.flac" > $LIBRARY_FILE #Add flac files  
find $LIBRARY_FOLDER -type f -name "*.mp3" >> $LIBRARY_FILE #Add mp3 files  
### Add other file types here  
#find $LIBRARY_FOLDER -type f -name "*.ogg" >> $LIBRARY_FILE #Add ogg files  
#find $LIBRARY_FOLDER -type f -name "*.wav" >> $LIBRARY_FILE #Add wav files

#########  
#Run Cog#  
#########

/Applications/Cog.app/Contents/MacOS/Cog-Application  

You will want to modify the script. Change the LIBRARY_FOLDER to point to a directory where all of your music files are located. You'll also want to add or remove the find statements to find the type of music files you are looking for (flac, mp3, ogg, etc).

  1. Set the permissions on the script to make it executable
chmod 755 /Applications/Cog.app/Contents/MacOS/Cog

Now whenever you run Cog, the library will be updated with your music files. If you add music files to your music directory, you will need to restart Cog.

comments powered by Disqus