I found some Matrix icons that I wanted to use on my Linux desktop. Unfortunately, the only available formats are for OSX or Windows (.ico). I prefer to use png, so I set out to convert the OSX-flavored icons to png.
You will need to download and install a few programs in order for this to work.
First, you need to get a copy of StuffIt for Linux. For those of you morally opposed to using close-source software, shame on you for even considering using Macintosh icons on your Linux desktop. Begone, you.
Next, download yourself a copy of icns2png [Local mirror].
Finally, grab these two scripts: clean and convert. Don’t forget to mark them executable.
Extracting the .bin/.hqx
I downloaded mtrx_icn.bin and saved it to ~/icons. Unstuff this .bin file to seperate the data in to two files.
stone@durin:~/icons$ unstuff mtxr_icn.bin
The Matrix Rebooted Icons.sit.info
The Matrix Rebooted Icons.sit.data
/home/stone/icons/The Matrix Rebooted Icons.sit.info ..
/home/stone/icons/The Matrix Rebooted Icons.sit.data ...........................................................................................................
stone@durin:~/icons$
Next, we need to extract the actual icons themselves. Without setting the parameters to tell unstuff how to treat the file, it will extract 0-byte Icons.
stone@durin:~/icons$ unstuff -e=unix -m=auto -t=on The\ Matrix\ Rebooted\ Icons.sit.data
...
(lots of files being extracted)
...
stone@durin:~/icons$
Fixing the filename
When unstuff extracts the Icon files, it leaves behind a carriage return (\r) embedded within the filename. Whoops.
stone@durin:~/icons$ ls -b The\ Matrix\ Rebooted\ Icons
Icon\r Read\ Me\ Please The\ Icons
I tried various ways of using find, xargs, and perl to do this but failed. So what we have here is clean. Simply, it will remove any control codes, including carriage returns and line feeds, from a filename. I spent way too much time trying to find a solution to this, so I hope it comes in handy for someone else.
#!/bin/sh
if [ ! -n "$1" ]; then
echo "Usage: clean.sh "
exit 0
fi
set -o noglob
find "$1" -name 'Icon*' -print | while read name ; do
newname="`echo $name | tr -d [:cntrl:]`"
mv "$name" "$newname" # do the move
done
~/icons$ ./clean The\ Matrix\ Rebooted\ Icons
stone@durin:~/icons$
Converting to png
Now that the filenames are fixed, we can get to our ultimate goal, converting the icons to png. For this, I hacked up another script, similar to clean.sh, and called it convert.
if [ ! -n "$1" ]; then
echo "Usage: convert.sh "
exit 0
fi
set -o noglob
find "$1" -type f -name 'Icon' -print | while read name ; do
icns2png "$name" # Convert to png
rm "$name" # remove old Icon
done
This one is simple enough that you can probably accomplish the same thing with find, -exec and xargs.
Matrix\ Rebooted\ Icons
Icon2PNG Linux Edition - (C) 2002 Mathew Eis
Converting The Matrix Rebooted Icons/Icon to The Matrix Rebooted Icons/Icon.png...
(repeat the above two lines for each Icon)
stone@durin:~/icons$
And you’re done. All of the OSX Icons have now been converted to png. Happy theming!