3

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

3

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

#!/bin/bash
C=`xdotool search --class $1 | tail -1`
if [ -z "$C" ]
then
    `$1 &`
else
    xdotool windowactivate --sync $C
fi

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 agree to our terms of service, privacy policy and cookie policy

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