2

I want to have renamed copies of some executables use different processes when executed.

System: Lubuntu 18.04 Desktop 64 bit.

For example:

$ sudo cp -a /usr/bin/mate-terminal  /usr/bin/mate-terminal-left
$ sudo cp -a /usr/bin/mate-terminal  /usr/bin/mate-terminal-right

From a launcher, I execute mate-terminal-left, which opens a terminal window on the left-half of the screen (due to my configuration settings for the OpenBox window manager).

Just for reference, I execute the following in that terminal:

$ ps -eo pid,command | grep -i 'terminal' | grep -ve 'grep'
19294 /usr/bin/mate-terminal-left

Now, with the left terminal still open, from another launcher, I execute mate-terminal-right, which should open a terminal window on the right-half of the screen. However, mate-terminal-right did not create a new process, but instead used the already active mate-terminal-left process, hence it opens on the left as well.

$ ps -eo pid,command | grep -i 'terminal' | grep -ve 'grep'
19294 /usr/bin/mate-terminal-left

When I open mate-terminal-right first, then it opens on the right, and then mate-terminal-left will also end up on the right.

I have found that some executables, such as Geany work well for my left and right renaming approach, but other executables such as mate-terminal and pcmanfm use the same process for all instances, even when started with different names.

My question is: How can I cause mate-terminal-left and mate-terminal-right to each open as separate processes?

In response to the comments below that suggest how to make a left and right terminal, thanks for your suggestions. However, that is not what my question asks. I only used the example to provide a concrete explanation of why someone might want the same executable running in multiple processes, rather than multiple instances running in the same process. I used mate-terminal only as an example, so I am not looking for another terminal.

The title of this question is what I am asking about: "How to cause copies of executables to open as separate processes?"

  • I suggest that you try with another light-weight terminal emulator program, for example: sakura or xterm. It seems xterm starts a separate process for each instance. But you can also use the associated bash process to identify the window. It is possible to use aliases to start terminal windows at specified locations: – sudodus Nov 26 '18 at 14:00
  • alias xterm-left='xterm -T 'xterm-left' -geometry +0-0 -fa default -fs 12' – sudodus Nov 26 '18 at 14:05
  • alias xterm-right='xterm -T 'xterm-right' -geometry -0-0 -fa default -fs 12' – sudodus Nov 26 '18 at 14:05
  • alias gterm-left='gnome-terminal --geometry=+0-0' – sudodus Nov 26 '18 at 14:22
3

What you're seeing here is fairly specific to mate-terminal itself, though more generally using some shared GNOME/GTK+ infrastructure that you might also find in other applications (you mentioned pcmanfm as well.)

When you launch a new copy of mate-terminal, perhaps from a different binary, it does create a new process for it. But mate-terminal is programmed to connect to D-Bus and try to look up a "factory", in which case it will pass it the arguments for what to start in the terminal and have the "factory" manage it, then terminate the new process. (If there's no factory, it will register itself as the factory, that's why the first process started will end up managing all terminals.)

The "factory" is found through its D-Bus path, /org/mate/Terminal/Factory, which is hardcoded into the binary. (Thus, replicated into other copies of the binary.)

In the case of mate-terminal specifically, you can disable this behavior by passing it a --disable-factory command-line argument. (See the man page for more details.)

That's fairly unique to how mate-terminal works. In particular, pcmanfm doesn't really do this the same way. It's unclear whether pcmanfm supports a way to launch a separate process, or if the only way it works is by communicating through D-Bus with an existing instance. (You'd have to look into pcmanfm to see if it does.)

  • 1
    Thank you for your explanation. This is exactly what I was looking for. I did not understand what a "factory" was before reading your information. I will mark your answer as being the solution. – GaryH. Nov 27 '18 at 18:29
0

Workaround: use a tool that creates separate processes

I have a shellscript, that creates three terminal windows on my main computer's desktop. With some ideas from my script I made the following attempt, which might work for you (or help you make what you need),

#!/bin/bash

vdockw=0 #68
hdockw=60

resol=$(xrandr|grep current|cut -d, -f2)
resol=$(<<< "$resol" sed 's/.*current //')
echo $resol
xres=${resol%% *}
yres=${resol##* }
echo $xres $yres
xmid=$(( (xres-vdockw)/2 ))
ymid=$((yres-hdockw))
echo $xmid $ymid

#xterm -title "term v" & pid=$!
sakura --title="term v" & pid=$!
sleep 0.5
wid=$(wmctrl -lp | grep "$pid" | cut "-d " -f1)
sleep 1
echo $pid $wid
wmctrl -i -r $wid -e 1,0,0,$xmid,$ymid

#xterm -title "term h" & pid=$!
sakura --title="term h" & pid=$!
sleep 0.5
wid=$(wmctrl -lp | grep "$pid" | cut "-d " -f1)
sleep 1
echo $pid $wid
wmctrl -i -r $wid -e 1,$((xmid+vdockw)),0,$xmid,$ymid

I tested that it works in two installed 18.04 LTS systems, Lubuntu (as it is) and in standard Ubuntu (with vdockw=68).

The shellscript uses the program packages sakura wmctrl and maybe xterm, which are available from the repository universe and can be installed with

sudo apt update
sudo apt install sakura wmctrl xterm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.