Breakertt Blog

一起实现梦想的故事!

Keep only one Gnome-Terminal instance (Ubuntu 22.04)

Breakertt's Avatar 2022-12-02 Linux

  1. 1. Method 1 - Remap gnome dock shortcut
  2. 2. Method 2 (Xorg only) - Reset gnome default terminal

Method 1 - Remap gnome dock shortcut

  1. Add gnome-terminal into dock (favortie), I move it to the third application, please change the number 3 in following article to the number you used.
  2. Disable terminal shortcut in Settings/Kebyaord/Keyboard Shortcuts
  3. Reset the shortcut to for start dock applications gsettings set org.gnome.shell.keybindings switch-to-application-3 "['<Ctrl><Alt>T']"

Method 2 (Xorg only) - Reset gnome default terminal

  1. Create a script at ~/bin/single_gnome_terminal.sh
#!/bin/sh
SERVICE='gnome-terminal'

if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
wmctrl -xa $SERVICE
else
$SERVICE
fi
  1. Enable execution permission
chmod +x ~/bin/single_gnome_terminal.sh`
  1. Install wmctrl
sudo apt-get install wmctrl
  1. Change default terminal
gsettings set org.gnome.desktop.default-applications.terminal exec single_gnome_terminal.sh

References:

  1. https://askubuntu.com/a/1194659
  2. https://askubuntu.com/a/87109
  3. https://unix.stackexchange.com/a/510376
本文最后更新于 天前,文中所描述的信息可能已发生改变