You are not logged in.

#1 2015-10-19 16:59:52

riddle00
Member
From: Lithuania
Registered: 2015-05-26
Posts: 81

[SOLVED] Shell script for focusing on existing terminal window

Hey,

I have a key F1 binded to this shell script:

#!/bin/sh

terminal_open="terminator --geometry=700x500 -T Shell"
terminal_focus="terminator"

 
# no terminal started, so start one
if [ -z  "`wmctrl -lx | grep terminator`" ]; then
    $terminal_open &
# terminal is opened, so focus on it
else
    wmctrl -x -R $terminal_focus
fi;

If no terminator if opened, it opens one, and if it is, it focuses on already existing one. However, I need it to focus only on the terminator which is named "Shell", ie the terminator opened using this scripts.
How should I edit my script smile ?

Thanks

Last edited by riddle00 (2015-10-19 17:44:37)

Offline

#2 2015-10-19 17:30:20

toz
Member
Registered: 2011-10-28
Posts: 497

Re: [SOLVED] Shell script for focusing on existing terminal window

Assuming you don't have two windows titled exactly "Shell", then -F should work:

-F     Window  name arguments (<WIN>) are to be treated as exact window
              titles that are case  sensitive.  Without  this  options  window
              titles  are  considered to be case insensitive substrings of the
              full window title.

One thing to keep in mind, your script doesn't check to see if a terminator window titled "Shell" exists before attempting to bring it into focus. You only check to see if a terminator window is open.

Offline

#3 2015-10-19 17:43:39

riddle00
Member
From: Lithuania
Registered: 2015-05-26
Posts: 81

Re: [SOLVED] Shell script for focusing on existing terminal window

Thanks. Also, I found that wmctrl -a seems to work well.

Offline

Board footer

Powered by FluxBB