I have a certain work environment with dozens of open Windows. How can I bring to the front a window with a known name/title programatically or using the command line?

link|improve this question

49% accept rate
feedback

2 Answers

up vote 1 down vote accepted

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

link|improve this answer
feedback

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

link|improve this answer
2  
No need for the brackets and backticks: if ! wmctrl -l | grep -q "$WINTITLE" – Dennis Williamson Sep 2 '10 at 2:09
feedback

Your Answer

 
or
required, but never shown

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