Managed to get onto a Gnome desktop
Okay, here goes:
Create your script like I mentioned above, save it in your home folder as 'init_media_keys.sh' or something, and make it executable.
Next, go to the System menu on the top task bar, select 'Preferences', then 'Sessions'.
A window should appear with three tabs in it, the last of which should be 'Startup Programs'.
Go to this tab, click add, and point it to your shell script.
Log out, log in again, and you should now be able to assign those keys in 'System' -> 'Preferences' -> 'Keyboard Shortcuts'.
The keys you assign should be persistent, i.e. you shouldn't need to assign them every time you log in.
I didn't have time to test whether or not this actually works, but it should... If not then at least the answer will be in that general direction.
Good Luck,
saltire