[openbox] key binding action to focus existing terminal

Vaughn Dickson vaughnd at gmail.com
Tue Apr 22 09:08:55 EDT 2008


What a fantastic little app! Thanks Delcides.

I put together this shell script to do exactly what I need. Funny thing is
that it's _still_ faster than the collection of applescripts I had on my mac
to play/pause itunes, etc. Man I missed this level of power and speed.

#!/bin/sh

terminal_wm_class="gnome-terminal"
terminal_exec="gnome-terminal"

# no terminal started, so start one
if [ -z "`wmctrl -lx | grep gnome-terminal`" ]; then
    $terminal_exec &
else
    # search for existing terminals on current desktop
    current_desk=`wmctrl -d | grep '*' | cut -d ' ' -f 1`
    term_on_this_desk=`wmctrl -lx | grep "$current_desk[
]*$terminal_wm_class" | cut -d ' ' -f 1`
    if [ -n "$term_on_this_desk" ]; then
        wmctrl -i -a $term_on_this_desk
    else
        # no terminals on current desktop, so just open the first one we
find
        wmctrl -x -a $terminal_wm_class
    fi;
fi;


On Tue, Apr 22, 2008 at 2:19 PM, Delcides F. Sousa Jr <delcides at gmail.com>
wrote:

> On Tue, Apr 22, 2008 at 8:42 AM, Vaughn Dickson <vaughnd at gmail.com> wrote:
> > Hi,
> >
> >  I'm used to Quicksilver's behaviour on Mac, where opening an
> application
> >  will just give it focus if it's already open. Is there a way to do this
> >  in openbox? Specifically for a terminal app. I have alt-e bound to open
> >  a terminal, but I'd rather have it focus the existing one on my current
> >  desktop/workspace.
> >
> >  Thanks,
> >  Vaughn
> >
> >
> >  ---
> >  To unsubscribe, send a blank email to openbox-unsubscribe at icculus.org
> >  Mailing list archives: http://icculus.org/cgi-bin/ezmlm/ezmlm-cgi?24
> >
>
>     You can use wmctrl and a bit of shell script to do this.
>
> Regards,
>
> Delcides.
>
> ---
> To unsubscribe, send a blank email to openbox-unsubscribe at icculus.org
> Mailing list archives: http://icculus.org/cgi-bin/ezmlm/ezmlm-cgi?24
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://icculus.org/pipermail/openbox/attachments/20080422/ac2645ba/attachment.htm>


More information about the openbox mailing list