Prevent Ctrl-Alt-T from opening a new terminal window when one already exist?

K. Rauscher

I would like to know if there is a way to make the Ctrl-Alt-T shortcut behave like it would on xfce. ie: if no terminal is open, open one, else focus on the existing one instead of opening a new one. Ideally without having to install things like xdotool.

I'm using manjaro linux with cinnamon (3.0.7) and gnome-terminal (3.20.2).

theGtknerd

The code in https://stackoverflow.com/questions/1380784/how-to-get-list-opened-windows-in-pygtk-or-gtk-in-ubuntu would tell you if a terminal is open and then you would need to focus the terminal. (Of course, if there is no terminal, open a new one.) Additionally you will need to hook up the Ctrl-Alt-T shortcut to the mini program you create that will control everything.

Edit with working code:

#!/usr/bin/python

import gi
gi.require_version('Wnck', '3.0')
from gi.repository import GdkX11, Gdk, Wnck
import subprocess   

screen = Wnck.Screen.get_default()
screen.force_update()  # recommended per Wnck documentation

# loop all windows
for window in screen.get_windows():
    window_name = window.get_name()
    print window_name
    if window_name == "your_terminal_name_here":
        now = GdkX11.x11_get_server_time(Gdk.get_default_root_window())
        window.activate(now)
        break
    continue
else:
    subprocess.call("gnome-terminal")

    # clean up Wnck (saves resources, check documentation)
window = None
screen = None
Wnck.shutdown()

Put this code in a file called check_window.py and link a shortcut to it in Preferences> Keyboard> Shortcuts. Make the file executable with chmod +x check_window.py Replace if window_name == "your_terminal_name_here": with the name of your terminal. If you run this 'app' one time with your terminal window open it will give you the name of your windows.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to make "CTRL + ALT + T" open new Terminal window when one is already open?

From Dev

How to make "CTRL + ALT + T" open new Terminal window when one is already open?

From Dev

How does one keep Alfred 2 from opening and entering your Terminal command in a new window when Terminal is already open?

From Dev

ctrl-alt-t opens new terminal window instead of new tab while gnome terminal is active window

From Dev

ctrl-alt-t opens new terminal window instead of new tab while gnome terminal is active window

From Dev

Mistyped <Ctrl>+<Alt>+<T> split existing terminal window

From Dev

Set default location for Terminal window opened with Ctrl+Alt+T

From Dev

Prevent Bootstrap modal window from opening in new tab / window

From Dev

Prevent Visual Studio from opening a new Firefox window when pressing F1?

From Dev

Opening a new terminal window in C

From Dev

Set a shortcut for opening Terminator (similar to Ctrl+Alt+T, but not replacing default terminal)

From Dev

Make "pro" style terminal default when opening new tab/window

From Dev

Kde, opening a new terminal window to ssh from bash script

From Dev

Prevent exe from opening a new command prompt window

From Dev

Prevent Ubuntu from opening a new Firefox window on every click

From Dev

Prevent gnome-terminal from changing directory when creating a new tab or window

From Dev

Prevent gnome-terminal from changing directory when creating a new tab or window

From Dev

How to prevent USC from opening a terminal when updating the cache?

From Dev

Prevent Revit window from opening

From Dev

Alt+Ctrl+T no longer opens a terminal

From Dev

Ctrl Alt T no longer opens terminal

From Dev

How can I distinguish a terminal window (GUI) from a console (CTRL+ALT+F3)?

From Dev

Portable method of opening a new terminal window?

From Dev

How to prevent opening of a terminal window when a "Show In Folder" action is selected for the downloaded file?

From Dev

Prevent opening of new Window on shift click in Firefox

From Dev

Why Ctrl+Shift+Alt+Down won't move a window one workspace down in 13.10

From Dev

Why Ctrl+Shift+Alt+Down won't move a window one workspace down in 13.10

From Dev

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

From Dev

Opening new window from ViewModel

Related Related

  1. 1

    How to make "CTRL + ALT + T" open new Terminal window when one is already open?

  2. 2

    How to make "CTRL + ALT + T" open new Terminal window when one is already open?

  3. 3

    How does one keep Alfred 2 from opening and entering your Terminal command in a new window when Terminal is already open?

  4. 4

    ctrl-alt-t opens new terminal window instead of new tab while gnome terminal is active window

  5. 5

    ctrl-alt-t opens new terminal window instead of new tab while gnome terminal is active window

  6. 6

    Mistyped <Ctrl>+<Alt>+<T> split existing terminal window

  7. 7

    Set default location for Terminal window opened with Ctrl+Alt+T

  8. 8

    Prevent Bootstrap modal window from opening in new tab / window

  9. 9

    Prevent Visual Studio from opening a new Firefox window when pressing F1?

  10. 10

    Opening a new terminal window in C

  11. 11

    Set a shortcut for opening Terminator (similar to Ctrl+Alt+T, but not replacing default terminal)

  12. 12

    Make "pro" style terminal default when opening new tab/window

  13. 13

    Kde, opening a new terminal window to ssh from bash script

  14. 14

    Prevent exe from opening a new command prompt window

  15. 15

    Prevent Ubuntu from opening a new Firefox window on every click

  16. 16

    Prevent gnome-terminal from changing directory when creating a new tab or window

  17. 17

    Prevent gnome-terminal from changing directory when creating a new tab or window

  18. 18

    How to prevent USC from opening a terminal when updating the cache?

  19. 19

    Prevent Revit window from opening

  20. 20

    Alt+Ctrl+T no longer opens a terminal

  21. 21

    Ctrl Alt T no longer opens terminal

  22. 22

    How can I distinguish a terminal window (GUI) from a console (CTRL+ALT+F3)?

  23. 23

    Portable method of opening a new terminal window?

  24. 24

    How to prevent opening of a terminal window when a "Show In Folder" action is selected for the downloaded file?

  25. 25

    Prevent opening of new Window on shift click in Firefox

  26. 26

    Why Ctrl+Shift+Alt+Down won't move a window one workspace down in 13.10

  27. 27

    Why Ctrl+Shift+Alt+Down won't move a window one workspace down in 13.10

  28. 28

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

  29. 29

    Opening new window from ViewModel

HotTag

Archive