Geany – Open a New Instance per Workspace When Opening a File

geanylinux-mintmate-desktopworkspaces

I'm using Mate 1.2.0 in Linux Mint 13. The two text editors i use are Gedit and Geany (v0.25): i use Geany for all my coding as i prefer the syntax highlighting and some other interface features.

One thing that bugs me though is this behaviour:

  • open a file in Geany in workspace 1
  • go to workspace 2
  • double click a file to open it (in Geany)
  • the desktop switches to workspace 1 again and opens the file in Geany.

When i do this in Gedit, it opens a new instance of Gedit in that workspace, which suits my style of working perfectly, where i have different projects open in each workspace.

I can start another instance of Geany from the programs menu, and move one into the other workspace, but it doesn't change the behaviour: I then see this:

  • open a file in Geany in workspace 1
  • go to workspace 2
  • start a new instance of Geany from the program menu (so i now have one per workspace)
  • double click a file to open it (in Geany)
  • the desktop switches to workspace 1 again and opens the file in the first instance of Geany.

So it's like it always opens a file in the "primary" Geany, and switches to whatever workspace that happens to be in.

Is there a way i can change this behaviour? I'd like it to be like so:

  • On opening a file: is there a Geany running in this workspace?
    • yes: open the file in that Geany
    • no: open a new Geany in this workspace and open the file in that.

I can't see an option relating to this in the settings. Any advice appreciated! thanks

Best Answer

Use this batch to open Geany. This will open a separate socket specific to each workspace.

For example, in Thunar, use 'open with other application' and point to this batch file.

#!/bin/sh

socket=`xprop -root _NET_CURRENT_DESKTOP`
socket=${socket##* }

if [ "$socket" ]
then
    if [ "$DISPLAY" ]
    then
        socket="${DISPLAY%.*}-$socket"
        socket=${socket#*:}
    else
        socket="NODISPLAY-$socket"
    fi
    exec geany --socket-file "/tmp/geany_socket_$socket" "$@"
else
    exec geany "$@"
fi
Related Question