Eject Key, Apple Pro Keyboard, and Linux

One thing I never liked about running Linux on my iMac is the fact that the eject key doesn’t work.
Using Debian, Gnome 2.8, Linux 2.6.8.

Well the problem is now solved, or fixed, thanks to a bit of scripting and the eject executable.

I wrote a little PHP script:

#!/usr/local/bin/php
if (!file_exists('/tmp/maccd')) {
$stat = 'closed';
}
else {
$stat = 'open';
}

if ($stat == 'closed') {
system('/usr/bin/eject');
$hd = fopen('/tmp/maccd', 'w');
fclose($hd);
}
else {
system('/usr/bin/eject -t');
unlink('/tmp/maccd');
}
?>

And put it in /usr/local/bin/maccd
Added a shortcut icon into the Gnome panel, and know all I have to do is click a button to eject and close my cd tray.
At least it’s easier than going to the Terminal.

Now if only I can somehow map the eject key to it…