How to write a command that would launch an application or if it was already running, would restore the minimized window?


The following bash script launch app or activate its window if app is already running:

C=`xdotool search --class $1 | tail -1`
if [ -z "$C" ]
    `$1 &`
    xdotool windowactivate --sync $C

And then use it on hotkey:

./launch.sh <some_app>

for example:

/path_to_script/launch.sh keepassx
  • Welcome to U/L, and thanks for coming back and posting the solution! – Sparhawk Jan 9 at 3:33

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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