You are not logged in.

#1 2011-04-14 15:09:37

student975
Member
From: Russian Federation
Registered: 2011-03-05
Posts: 613

[openbox] focus or execute - how to?

I'd want to key-bind an execution of an application (it is geany) at a single-instanse mode: if the app is already running, just focus it instead of starting new instanse.

How to?


"I exist" is the best myth I know..

Offline

#2 2011-04-14 16:52:26

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: [openbox] focus or execute - how to?

Write a script to check if the pidof geany returns anything. if yes, then pull that pid else start a new instance of the app.


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#3 2011-04-14 17:06:03

student975
Member
From: Russian Federation
Registered: 2011-03-05
Posts: 613

Re: [openbox] focus or execute - how to?

Inxsible wrote:

Write a script to check if the pidof geany returns anything. if yes, then pull that pid else start a new instance of the app.

There isn't a pid, but there is a socket:

$ netstat -l | grep geany_socket
unix  2      [ ACC ]     STREAM     LISTENING     528982 /tmp/geany_socket.cc71320d

Unfortunately I don't know how to use it. Is there some example I can adapt?

Last edited by student975 (2011-04-14 17:06:29)


"I exist" is the best myth I know..

Offline

#4 2011-04-14 19:49:44

student975
Member
From: Russian Federation
Registered: 2011-03-05
Posts: 613

Re: [openbox] focus or execute - how to?

Digging here and there (and being far from bash programming) I have "wrote" the script:

#!/bin/bash

CTX="\[sysFiles\] - Geany"
APP=$(wmctrl -l | grep "$CTX" | awk '{print $1}')

if [ -z "$APP" ]; then
  geany
else
  wmctrl -i -a $APP
fi

exit 0

It seems to work as expected, but I'm not sure it is a good solution. So prefer to wait for critics before marking the topic as SOLVED.

Last edited by student975 (2011-04-14 19:51:41)


"I exist" is the best myth I know..

Offline

Board footer

Powered by FluxBB