[=>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.

: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.

:open_file_folder: 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;

: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

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]
Name=x-terminal-emulator
GenericName=Terminal
TryExec=x-terminal-emulator
Exec=x-terminal-emulator
Icon=utilities-terminal
Type=Application
Categories=System;GTK;Utility;TerminalEmulator;
StartupNotify=true
Keywords=GNU;terminal;shell;prompt;command;commandline;

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.

: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::

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:

Replace

            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" )

With

            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:

killall mate-panel

:information_source: This should relaunch mate-panel in accordance with dconf schema /org/mate/desktop/session/required_components panel but if however it doesn't reload, then in your current terminal instance launch mate-panel & and you'll get it back.

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.

1 Like