Skip to content

Instantly share code, notes, and snippets.

@sirupsen
Created March 23, 2010 13:45
Show Gist options
  • Save sirupsen/341179 to your computer and use it in GitHub Desktop.
Save sirupsen/341179 to your computer and use it in GitHub Desktop.
Just a single terminal. Please.
#! /bin/bash
WINTITLE="sakura" # Name of the window (or part of it)
PROGRAMNAME="sakura" # Name of the program, so it can be opened if there's no window currently
# Lists all windows, if there's one containing $WINTITLE it'll return 1, and bring the current instance of the program to the front.
if [ `wmctrl -l | grep -c "$WINTITLE"` != 0 ]
then
wmctrl -a "$WINTITLE"
# Else, it'll launch a new instance
else
$PROGRAMNAME &
fi
# We're good!
exit 0
@sirupsen
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment