Gnome (Ubuntu): how to bring a program window to the front using a command line from the terminal?
I used to use wmctrl -a <name>
, which works fine, but recently switched to xdotool
, e.g.:
xdotool search --name <name-or-regex-for-name> windowraise
It has many other features too.
To install:
sudo apt-get install xdotool
Well, after sudo apt-get install wmctrl
-ing, you can play with this bash script:
#! /bin/bash
WINTITLE="Mail/News" # Main Thunderbird window has this in titlebar
PROGNAME="mozilla-thunderbird" # This is the name of the binary for t-bird
# Use wmctrl to list all windows, count how many contain WINTITLE,
# and test if that count is non-zero:
if [ `wmctrl -l | grep -c "$WINTITLE"` != 0 ]
then
wmctrl -a "$WINTITLE" # If it exists, bring t-bird window to front
else
$PROGNAME & # Otherwise, just launch t-bird
fi
exit 0
Which I found here