22

If you have gnome-terminal running, and want a new instance of the program, you might think that running gnome-terminal & from a shell would do the trick.

Astonishingly, this new instance behaves like some insipid Windows or Mac program; it only sends a message to the existing, running gnome-terminal to create a new window. If this one gnome-terminal process crashes, you lose all of the terminal windows!

(Of course, each window has its own shell, which is an independent process, but the actual terminal emulator and its GUI are managed from a single instance of the application.)

How can we create independent instances of gnome-terminal, each running in their own process, so that killing that process only destroys the window(s) associated with that process?

Kaz
  • 8,273
  • You may have success with gnome-terminal --disable-factory, however support for it is apparently being witdrawn – steeldriver May 07 '15 at 01:01
  • @steeldriver It seems to be working; care to make it into an answer? I don't care about support being withdrawn. Why is this so hard to find? Because the documentation for --disable-factory doesn't use any standard terminology like "start in a new process (or address space); do not re-use the existing instance". – Kaz May 07 '15 at 01:06
  • Compare http://unix.stackexchange.com/questions/323663/ – JdeBP Nov 17 '16 at 20:02
  • 3
    I can't believe the people running these projects keep making such crappy decisions. Did we learn nothing? Who cares about sparing some kilobytes of RAM? One would think that keeping the terminals from crashing each other should be the #1 priority. Back to rxvt I guess. – Tobia Nov 21 '16 at 12:12
  • In fact, I can recommend rxvt to anybody wanting a true multi-process terminal. It has Truetype font support, re-wrapping of long lines, and most other features of modern terminals. – Tobia Nov 22 '16 at 13:50

3 Answers3

19

Due to the new client/server architecture (details here) you'll have to start separate instances of gnome-terminal-server. To do that you could use the --app-id switch:

/usr/lib/gnome-terminal/gnome-terminal-server --app-id my.first.Terminal

then use the client (with the same app-id) to create terminals1 inside the new server :

gnome-terminal --app-id my.first.Terminal
gnome-terminal --full-screen --app-id my.first.Terminal
......

Another instance:

/usr/lib/gnome-terminal/gnome-terminal-server --app-id my.second.Terminal

and terminals:

gnome-terminal --geometry 80x24+200+200 --app-id my.second.Terminal
gnome-terminal --app-id my.second.Terminal
.....

Path to gnome-terminal-server might be different on your system.


1: Note that "you have 10 seconds to use the client to create a terminal inside the new server".

don_crissti
  • 82,805
  • Can you give a working example or take a look at this question?: http://unix.stackexchange.com/questions/304269/how-to-use-gnome-terminal-with-new-client-server-architecture-as-wrapper – cprn Aug 29 '16 at 16:57
  • @CyprianGuerra - in a gnome-terminal open two tabs: in the first tab run the 1st command in my example (that is to start the new server) then, in less than 10 seconds, switch to the second tab and run the 2nd command (to start a new client) customized per your needs... – don_crissti Aug 29 '16 at 19:36
  • Tabs... I'll try. For now I can tell it doesn't work inside screen. – cprn Aug 30 '16 at 00:39
  • Are the tabs requirement? As in: does the client terminal process have to be a child of the server? – cprn Dec 16 '16 at 14:31
  • @CyprianGuerra - it was just an example, they're not required from what I can see... – don_crissti Dec 16 '16 at 17:49
  • Well, I moved away from gnome-terminal but I couldn't run it if my life depended on it. Whenever I started the server it would just die in 10 seconds regardless of me trying to connect the client in other tab / terminal instance / screen buffer. I think it simply doesn't work. – cprn Jan 08 '17 at 00:08
  • Error creating terminal: The name my.new.terminal was not provided by any .service files So, see perhaps https://chrisirwin.ca/posts/multiple-instances-of-gnome-terminal/ – stevesliva Mar 19 '18 at 19:02
11

According to man gnome-terminal, the option you're looking for appears to be the confusingly-named

   --disable-factory
             Do not register with the activation name server, do 
             not re-use an active terminal.

However, the option is apparently removed in more recent releases so should not be relied on.

steeldriver
  • 81,074
  • I tried rxvt, aterm, eterm, xterm, Terminator and a few others. They all easily run as separate processes, of course, but suck in other ways. The documented resizing hotkeys of rxvt wouldn't work. Aterm and xterm plain suck in that department. Terminator has weird resizing that changes the font size without the window size. ETerm just has completely wacky resizing with four fixed fonts; I played with the options for about 30 minutes, then uninstalled it. – Kaz May 07 '15 at 19:13
  • @Kaz xterm + xdotool --window "$WINDOWID"? – Gilles 'SO- stop being evil' May 07 '15 at 19:52
  • @Kaz You're probably way over it but I highly recommend urxvt over rxvt. And yes, gnome-terminal is still graphically superior but I somehow learned not to miss it. It probably has a lot to do with new window manager (using i3 now but it's not for everyone). – cprn Jan 08 '17 at 00:14
  • Look into any of the dozen other libvte based terminals? Gnome-terminal is just one application that ends up interfacing with that library on the backend unlike the rest mentioned above that use their own terminal implementations. – dragon788 Aug 07 '18 at 18:19
3

I have been struggling with mc being in same alt-tab group as other terminal windows and found this solution.

https://chrisirwin.ca/posts/multiple-instances-of-gnome-terminal/

The guy (Chris Irwin) solves it for his mail routine. I did the same for mc with full success apart from mc icon within alt-tab but that is fine.

You'll need 3 files:

/usr/share/dbus-1/services/org.gnome.Terminal-mc.service

[D-BUS Service]
Name=org.gnome.Terminal-mc
SystemdService=gnome-terminal-server-mc.service
Exec=/usr/lib/gnome-terminal-server --class=org.gnome.Terminal-mc --app-id org.gnome.Terminal-mc

/usr/lib/systemd/user/gnome-terminal-server-mc.service

[Unit]
Description=GNOME mc Terminal Server
[Service]
KillMode=process
Type=dbus
BusName=org.gnome.Terminal-mc
ExecStart=/usr/lib/gnome-terminal-server --class=org.gnome.Terminal-mc --app-id org.gnome.Terminal-mc

/usr/local/share/applications/mc.desktop

This is your desktop entry for midnight commander. Either edit it directly in /usr/share/applications/... or move it from there to /usr/local/share/applications/mc.desktop to stress out that it is your own modified copy. In any case, Exec entry should be modified to have gnome-terminal --app-id org.gnome.Terminal-mc -e mc

Exec=gnome-terminal --app-id org.gnome.Terminal-mc --hide-menubar --geometry=102x35 -e mc

Archive with all the above

https://we.tl/t-6rH5jduMG7 This is .tar.gz to unpack in your /. It will create files from above, plus .svg icon for mc.

Lauri
  • 151