Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Gedit, if you have multiple Gedit windows open, and then open a file, Gedit chooses to open it in the most recently active window. I like this behaviour, i think it's intuitive.

In Geany, which i otherwise prefer to Gedit, the rule for which instance to use seems to be "the oldest one". What's worse, if that instance is open on another desktop, it moves that instance into your current desktop as well. This effectively makes it impossible to work with multiple Geany windows, which is really annoying.

Does anyone know of a way i can make Geany open files in the most recently active (ie "looked at") instance of Geany? I'm using the most up to date version (0.21).

share|improve this question
    
I've never seen Geany with more than one window open. – Ignacio Vazquez-Abrams Apr 2 '12 at 11:29
    
In the latest version you can right click on a tab and choose "Open in new window". (again, annoyingly, it leaves it open in the original window as well as opening it in a new one) – Max Williams Apr 2 '12 at 13:48

Using Geany 1.22 there may be a workaround which is pretty close to what you want to do.

According to the manual on http://www.geany.org/manual/current/#command-line-options you can use

--socket-file

to specify the socket file with which to communicate with the Geany instance.

Putting the following in a script will get you an instance per workspace:

#!/bin/bash
geany --socket-file=/tmp/geany-sock-$(xprop -root _NET_CURRENT_DESKTOP | awk '{print $3}') ${1+"$@"}

(It also passes on the command line args to geany).

share|improve this answer
    
This is great. I prefer to define an "edit" function in my .XXXXrc file and also tack on '&' to let it run in the background. – troutinator Sep 30 '13 at 16:36
    
this caused infinitely many geany processes to spawn. – shrx Jun 14 at 10:25

Sadly there is no way to configure this behaviour. Several months ago, I asked some Geany plugin developers about this and it seems the only way to change this is to write the code yourself and send them a patch.

share|improve this answer

This perhaps should have been a comment on the response of Rikard, but I will present it as an alternative response. I noticed that his solution makes the computer (with Ubuntu 14.04) non responsive if we use it when the original script (without the socket option) is already running. So, I felt it will good to make the script exit in that case. If you name the script geany, put it in a directory before /usr/bin or wherever is the original in the PATH.

#!/bin/bash
for pid in $(pgrep "geany")
do
 cmd=$(ps -p $pid -o cmd)
 if [[ "$cmd" = *"/usr/bin/geany"* ]] && [[ "$cmd" != *"socket"* ]] ; then
  echo original geany already running
  exit
 fi
done
/usr/bin/geany --socket-file=/tmp/geany-sock-$(xprop -root _NET_CURRENT_DESKTOP | awk '{print $3}') ${1+"$@"}
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .