Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to do the following in Ubuntu? If so, can someone point me in the right direction.

Say you want to set a keyboard shortcut to do the following:

For examples sake, set Alt+F to open Firefox and maximize it, but only if Firefox is not already running. If it is running and not maximized, then maximize the most recently touched Firefox window. If it is maximized, then minimize Firefox.

share|improve this question

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:

  1. open up gconf-editor
  2. 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!!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.