Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
switch to gnome-terminal if it's open, otherwise launch a new one
#!/bin/bash
read -r win_found <<<$(wmctrl -l -p | awk '{print $1,$3}' | while read -r wins; do ps -o command= -p "${wins/0x* /}" | grep -q gnome-terminal && echo "${wins/ */}" && break; done)
if [ -z "$win_found" ]; then
gnome-terminal
else
wmctrl -i -a $win_found
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.