[14.04, 19.10] Force use of x-terminal-emulator for default terminal

:question: Haven't you written about this before?
Yes, I've had written about this particular topic before. But since "Default terminal" isn't something that appears in a search here, and it wasn't all in one place to my knowledge. I figured a new guide was justified. That, and I am really, really lazy.

:anger: Why is this so difficult?!
This is Linux, or at least, Linux "as usual." Very little comes easy initially, but fear not — Given time, creating solutions with your own hand is something you will likely come to appreciate.

:ubuntu_mate: Introduction

If you're just getting into Linux, or had been for awhile and wanted to use something other than mate-terminal then there is no limit for the options available to you. But no matter your preference, you'll had noticed there's no easy way to change it all at once. You can change the default terminal Caja uses, but those changes don't apply to anything which could prompt x-terminal-emulator which is why MATE Menu doesn't respect your specification there, and you also cannot normally select x-terminal-emulator as a preferred application to make your life easier.

The intention of this guide is to make your future life easier by doing something in the present. When finished, you should be able to change the default terminal everywhere with one single action.

:files: Fixing the file manager

Unfortunately, the default terminal according to update-alternatives isn't respected as a selection for Preferred Applications. That shouldn't stop you from making it a reality, however and with a little extra effort you'll be able to easily select it there. To begin, start in your terminal :key: ;

:memo: If not pluma, replace with your preferred text editor.

:heavy_dollar_sign: In x-terminal-emulator:

sudo pluma /usr/share/applications/x-terminal-emulator.desktop

:key: An alternative using gvfsd for people who want to do it the new way:
:cog: In Run Application:

pluma admin:///usr/share/applications/x-terminal-emulator.desktop

Then, put this in it:

:information_source: Most of this was taken from mate-terminal.desktop. You can also probably pare it down further, I didn't tamper with too much of the defaults to ensure success.

:spiral_notepad: In your preferred text editor, for x-terminal-emulator.desktop:

[Desktop Entry]

Save it, then when you next look in Preferred Applications, x-terminal-emulator will show up there. Once defined, it should open whatever x-terminal-emulator is configured for. For most people, this will usually be to open a terminal from the file manager.

:computer: Fixing MATE's window manager

A new wrinkle introduced with Ubuntu 19.10 it seems, there is a keybind within marco to define opening the terminal with Super + T but again, it only respects MATE's preference, not yours. So let's beat that into submission while we're at it.

:heavy_dollar_sign: In x-terminal-emulator:

gsettings set org.mate.marco.keybinding-commands command-4 'x-terminal-emulator`

:mate: Fixing MATE Menu

If you are a user of the Advanced MATE Menu, you'll notice the terminal doesn't open to whatever you defined as default. While unfortunate, it is just as easy as ever to resolve. But first, back up;

:information_source: You can also simply open this file in your preferred text editor and save as something else, but this is intended to be the faster method for people in a rush to complete this task.

:heavy_dollar_sign: In x-terminal-emulator:

cd /usr/lib/python3/dist-packages/mate_menu/plugins
sudo cp ./system_management.py system_management_old.py

:clock3: Older versions of this software use an older version of Python. If not python3 try python2.7 instead. I am probably missing information for older revisions beyond that.

:heavy_plus_sign: Optionally while you're there, you could rename the current iteration, then link it :link::

:heavy_dollar_sign: In x-terminal-emulator:

sudo mv system_management.py system_management_new.py
sudo ln -s $PWD/system_management_new.py ./system_management.py

Afterward, do the following:

:heavy_dollar_sign: In x-terminal-emulator:

sudo pluma ./system_management.py

:spiral_notepad: In your preferred text editor, for system_management.py @ lines 180-185:

            if pathExists("mate-terminal"):
                Button4.connect( "clicked", self.ButtonClicked, "mate-terminal" )
            elif pathExists("xdg-terminal"):
                Button4.connect( "clicked", self.ButtonClicked, "xdg-terminal" )
            elif pathExists("x-terminal-emulator"):
                Button4.connect( "clicked", self.ButtonClicked, "x-terminal-emulator" )


            if pathExists("x-terminal-emulator"):
                Button4.connect( "clicked", self.ButtonClicked, "x-terminal-emulator" )
            elif pathExists("xdg-terminal"):
                Button4.connect( "clicked", self.ButtonClicked, "xdg-terminal" )
            elif pathExists("mate-terminal"):
                Button4.connect( "clicked", self.ButtonClicked, "mate-terminal" )

:information_source: You must copy the spaces, too! To do this without copying the above, move lines 184 and 185 above line 181, then move what is now at lines 182 and 183 above line 185. Then swap if and elif in lines 180 and 184.

:link: Did you make that link earlier? If you goofed and you need the MATE Menu to work again in quick order, then you can do this:

:heavy_dollar_sign: In x-terminal-emulator:

sudo rm -rf ./system_management.py
sudo ln -s $PWD/system_management_old.py system_management.py

When finished, save your changes. You will also need to restart mate-panel for changes to apply:

:heavy_dollar_sign: In x-terminal-emulator:

mate-panel --replace

Then proceed to the whole point of this ordeal;

:terminal: Changing x-terminal-emulator

All that's left to do is to adjust update-alternatives so it uses your preference:

:heavy_dollar_sign: In x-terminal-emulator:

sudo update-alternatives --config x-terminal-emulator

You will be presented with a menu, which will allow you to select the default terminal. Based on the changes you performed above, this will also change the default terminal for MATE Menu and Caja's "Open in Terminal" action, as nature intended.

:right_anger_bubble: Corrections

Whoopsie, I edited the wrong file! No harm, no foul anyway. So MATE Menu section is fixed, and the correct spacing is in each monospaced line.

In the most recent edit I fixed up formatting to be on-par with other posts, as well added in new information about the Super + T shortcut.

A previous revision of this guide suggested to relaunch mate-panel by killing it, rather than the ore sane and sensible method of restarting it. This also allowed me to remove the "What should happen" post-text.