rbreaves / kinto

Mac-style shortcut keys for Linux & Windows.
http://kinto.sh
GNU General Public License v2.0
4.42k stars 213 forks source link

Add support for GNOME Console #669

Closed BomberFish closed 2 years ago

BomberFish commented 2 years ago

Console was introduced in GNOME 42 intended as a replacement for the Terminal app, and currently kinto does not remap shortcuts for it.

RedBearAK commented 2 years ago

@BomberFish @rbreaves

I was just about to look into that. Oddly, it's not yet included in Ubuntu 22.04 or Fedora 36. Looks like it can be installed (as gnome-console) but it's still marked as a beta version in both. Is there a distro that is already using it to replace GNOME Terminal, or did you install it manually?

Has a kind of strange WM_CLASS:

WM_CLASS(STRING) = "org.gnome.Console", "Kgx"

You have to take the second part in quotes to make it work with xkeysnail, so the list will just include an entry for "Kgx". I'll add a comment to the line and also include "org.gnome.Console" in case they decide to change the "Kgx" later.

In the meantime, if you add these lines to your kinto.py config file and restart Kinto, everything should work in Console (barring any unusual new shortcuts which may be different from other terminals):

# Use the following for testing terminal keymaps
# terminals = [ "", ... ]
# xbindkeys -mk
terminals = [
    "alacritty",
    "deepin-terminal",
    "eterm",
    "gnome-terminal",
    "guake",
    "hyper",
    "io.elementary.terminal",
    "kinto-gui.py",
    "kitty",
    "Kgx",           # GNOME Console terminal app
    "konsole",
    "lxterminal",
    "mate-terminal",
    "org.gnome.Console",
    "qterminal",
    "st",
    "sakura",
    "station",
    "tabby",
    "terminator",
    "termite",
    "tilda",
    "tilix",
    "urxvt",
    "xfce4-terminal",
    "xterm",
]
terminals = [term.casefold() for term in terminals]
termStr = "|".join(str('^'+x+'$') for x in terminals)

Hmm, seems to be a conflict with tab navigation between the Ubuntu version and the Fedora version. Annoying. Still trying to figure that out.

RedBearAK commented 2 years ago

@BomberFish @rbreaves

Figured out what the issue was with the tab navigation shortcuts. I have a remap in Ubuntu right at the beginning of the GUI block to implement tab navigation with Cmd+Shift+Braces in many different Linux GUI apps, a lot of which seem to respond to Ctrl+PgUp/PgDn.

A number of different Mac applications with tabbed interfaces have responded to the Cmd+Shift+Braces shortcuts. So I just made it a general shortcut.

# None referenced here originally
# - but remote clients and VM software ought to be set here
# These are the typical remaps for ALL GUI based apps
define_keymap(lambda wm_class: wm_class.casefold() not in remotes,{
    ### Tab navigation
    K("RC-Shift-Left_Brace"):       K("C-Page_Up"),                             # Go to prior (left) tab
    K("RC-Shift-Right_Brace"):      K("C-Page_Down"),                           # Go to next (right) tab
...

So if any particular app wants a different remap to something like Ctrl+Shift+Tab/Ctrl+Tab for that same function, the override has to come before the GUI code block, or it won't work.

The set of code blocks below gets me tab nav with Ctrl+Shift+Braces and Ctrl+Shift+Arrows in terminal apps like GNOME Terminal (which wants Ctrl+PgUp/PgDn), and now apps like GNOME Console, Angry IP Scanner and jDownloader (which want Ctrl+Shift+Tab/Ctrl+Tab). The rest of the "General GUI" block comes after the end of this pasted code:

# Tab navigation overrides for apps that use Ctrl+Shift+Tab/Ctrl+Tab instead of Ctrl+PgUp/PgDn
define_keymap(re.compile("org.gnome.Console|Kgx|deepin-terminal|Angry*IP*Scanner|jDownloader", re.IGNORECASE),{
    ### Tab navigation
    K("RC-Shift-Left_Brace"):   K("C-Shift-Tab"),       # Tab nav: Go to prior tab (left)
    K("RC-Shift-Right_Brace"):  K("C-Tab"),             # Tab nav: Go to next tab (right)
    K("RC-Shift-Left"):         K("C-Shift-Tab"),       # Tab nav: Go to prior tab (left)
    K("RC-Shift-Right"):        K("C-Tab"),             # Tab nav: Go to next tab (right)
},"Tab Navigation for apps that want Ctrl+Shift+Tab/Ctrl+Tab")

# Special overrides for terminals for shortcuts that conflict with General GUI block below.
define_keymap(re.compile(termStr, re.IGNORECASE),{
    K("M-Backspace"):           K("M-Shift-Backspace"), # Wordwise delete word left of cursor in terminals
    K("M-Delete"):              [K("Esc"),K("d")],      # Wordwise delete word right of cursor in terminals
    K("RC-Backspace"):          K("C-u"),               # Wordwise delete line left of cursor in terminals
    K("RC-Delete"):             K("C-k"),               # Wordwise delete line right of cursor in terminals
    ### Tab navigation
    K("RC-Shift-Left"):         K("C-Page_Up"),         # Tab nav: Go to prior tab (Left)
    K("RC-Shift-Right"):        K("C-Page_Down"),       # Tab nav: Go to next tab (Right)
},"Special overrides for terminals")

# None referenced here originally
# - but remote clients and VM software ought to be set here
# These are the typical remaps for ALL GUI based apps
define_keymap(lambda wm_class: wm_class.casefold() not in remotes,{
    K("RC-Shift-Left_Brace"):   K("C-Page_Up"),         # Tab nav: Go to prior (left) tab
    K("RC-Shift-Right_Brace"):  K("C-Page_Down"),       # Tab nav: Go to next (right) tab
...
RedBearAK commented 2 years ago

@BomberFish @rbreaves

GNOME Console still seems to be in the early phase of development where it's missing a lot of features that exist in GNOME Terminal. This is probably why both Ubuntu 22.04 and Fedora 36 didn't include it as the default terminal app. But that will probably change by the time Fedora 37 and Ubuntu 23.04 come out.

I saw the same thing with the early versions of the new GNOME text editor, but features were added rapidly to make it a decent replacement for Gedit.

RedBearAK commented 2 years ago

@BomberFish @rbreaves

PR #670 will add GNOME Console to the list of terminals for basic support.

I'll put the proposed tab navigation fixes in a different PR.

RedBearAK commented 2 years ago

@BomberFish @rbreaves

PR #671 will bring full support for tab nav to GNOME Console.