Ubuntu – Ctrl-Alt-t opens root terminal instead of normal terminal

command linerootterminator

I installed Terminator and made it my default terminal with this solution, but now CtrlAltT opens Terminator as a root terminal. How do I get it to open Terminator as a normal terminal?

enter image description here

Best Answer

What happens ?

TL;DR #1: Basically, you spawn x-terminal-emulator and Unity searches for anything that has x-terminal-emulator in their shortcut file.

  1. You press Ctrl+Alt+T, which spawns x-terminal-emulator. In Debian Alternatives system, x-terminal-emulator is a symlink to a whatever terminal emulator app you would want to use.
  2. Unity's mechanisms search through the list of "shortcut" files in /usr/share/applications. It finds the gksu.desktop file, which has Exec=gksu /usr/bin/x-terminal-emulator line and then takes out the line Name=Root Terminal. That Root Terminal is then displayed on the Unity's panel

Why the same thing doesn't happen with gnome-terminal?

TL;DR #2: gnome-terminal is actually spawned by a wrapper script, to which the default shortcut is linked.

When you run sudo update-alternatives --config x-terminal-emulator you are presented with choices, but none of them is /usr/bin/gnome-terminal. Rather you have /usr/bin/gnome-terminal.wrapper which is a perl script that sets up gnome-terminal first ! If you read through that script, at the end it has the following line :

exec('gnome-terminal',@args);

The exec call then spawns /usr/bin/gnome-terminal , as separate app. Unity again searches /usr/share/applications/ directory and finds gnome-terminal.desktop file which has Name=Terminal line, and it shows it on the launcher.

What can be done?

TL;DR #3: reassign keyboard shortcut,use custom wrapper, or create custom .desktop file. I recommend the .desktop way.

Easiest way is to reassign the shortcut. Use gsettings for that

 gsettings set org.gnome.desktop.default-applications.terminal exec 'sakura'

But that still doesn't solve the quirk with Unity's dash. My preferred solution is to create the custom .desktop file /usr/share/applications/x-terminal-emulator.desktop with the following contents

[Desktop Entry]
Name=MY CUSTOM TERMINAL
Encoding=UTF-8
Exec=/usr/bin/x-terminal-emulator
Icon=gksu-root-terminal
StartupNotify=true
Terminal=false
Type=Application
Categories=GTK;Utility;TerminalEmulator;

That way , you don't have to change anything, but Unity will display MY CUSTOM NAME on the launcher.

Third way, if you are feeling adventurous is to write a wrapper script, something like this:

   #!/bin/sh
   exec /path/to/terminal-emulator ${1+"$@"}

Then you can add it as one of the options in the alternatives system using

sudo update-alternatives   --install /path/to/wrapper name /path/to/wrapper priority 

Side note: priority is an integer, such as 10.

More info

Related Question