My recommendation would be to do it with a custom shell script. I'm not sure how to test if a window is maximised, but to check if it's running you could grep the output of ps:
ps -elf | grep username | grep firefox
There is probably a neater way of doing that, but speed isn't particularly of the essence.
Assuming you're running gnome under ubuntu, to run a custom script given a keyboard shortcut:
- open up gconf-editor
- go to apps->metacity
There are 2 folders of importance in there:
- global_keybindings - this is used to specify the keybinding
- keybinding_command - this is used to specify the command to run
In the global folder you'll see run_command_X and in the keybinding_command there is command_X. The integer X is the association between the binding and the command.
It might be possible to have different scripts bound to the same keystroke depending on the app that currently has focus. So for example Alt-F would always run the launchFirefoxIfNotOpen script, but the minimiseFirefox would only run if firefox received the keystroke. Not sure it's possible, just an idea.
Hope this helps and good luck!!