Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Question) Running toshy with i3 window manager #294

Closed
jfernandez opened this issue Jun 17, 2024 · 6 comments
Closed

(Question) Running toshy with i3 window manager #294

jfernandez opened this issue Jun 17, 2024 · 6 comments
Assignees
Labels
question Further information is requested

Comments

@jfernandez
Copy link

jfernandez commented Jun 17, 2024

I'd like to run toshy in i3wm. My ideal setup would be:

  • The key to the left of the spacebar (Alt) continues to be the "command" key.
  • I configure in iwm3 for Super (left of Alt) be the mod key.

By default, toshy appears to intercept the Super key so I have to disable it for i3wm to work correctly.

Is it possible to run toshy in i3wm? How would I go about disabling all Super key overrides so that i3wm can work correctly?

Ultimately, what I care for the most is the copy/paste and close tab key binds

@jfernandez jfernandez added the question Further information is requested label Jun 17, 2024
@RedBearAK
Copy link
Owner

@jfernandez

OK, let's get (me) solidly oriented first, so we know how to move forward. If these are standardized shortcuts for i3wm we are talking about, and you can succeed at this, maybe we can even include it in the default config.

So first thing is to get grounded in what happens to modifier keys. They get remapped prior to keymaps full of combo remaps being evaluated. All of this happens on each key press, very fast. Has to happen that way to respond to new context info, like when you move from one app window to another.

The basic modmaps I inherited from Kinto shift the Super key (the key code) over onto the left Ctrl key, and then when an app window is identified as a "terminal", the Super key code vanishes. It doesn't exist. But that's not a big deal, and you shouldn't care about where the Super key code went. This is just an explanation for why the Super key position doesn't currently do what you want. (Its identity changes while Toshy is active, like other modifier keys.)

What matters more in this case is that the physical location of the Super key (on a PC keyboard) becomes an Alt key (LEFT_ALT). This is the same for both GUI apps and terminals, so it shouldn't require any extra fixes for use in terminals.

What we want to do is not disable the modmap of Super, or disable a ton of individual remaps in the existing config, but rather implement a set of custom overrides for that physical key position. Which remember is an Alt key, specifically LEFT_ALT. We might or might not want to use LA for the remaps to preserve the "Alt" functionality of the physical Super key on the right side, but we'll see how badly the overrides actually interfere with what might need an Alt key or that physical position.

So a big question here is what is the list of shortcuts that need to work correctly in i3wm for it to be usable? If you can provide that list, we can start doing a personal override keymap that will apply itself specifically to i3wm.

And I have never actually tested in i3wm so it would be a good idea to run toshy-env and see how the environment module identifies the window manager. I suspect it will be 'i3', but I've never actually seen it myself.

Ultimately it should be possible to preserve most of the functionality of Toshy (all the hundreds of app-specific remaps for things like browsers, file managers and code editors) with just a few things maybe getting overridden by your custom keymap, which will act globally as long as you are in i3wm.

Before I forget, you will most likely need to just completely disable the "Option-key special characters" layout from the tray icon menu or the Preferences app window, since the key you'll be applying overrides to is the virtualized Option key used for that entire special character scheme. Which uses a Unicode character entry shortcut that only works with ibus and comes before the user_apps section where you're going to place your overrides, so it would probably interfere with your attempts to use that key for other things. (Unless the only shortcuts you need for i3wm involve something like the arrow keys where there are no special characters available.)

@jfernandez
Copy link
Author

So a big question here is what is the list of shortcuts that need to work correctly in i3wm for it to be usable? If you can provide that list, we can start doing a personal override keymap that will apply itself specifically to i3wm.

Here is the cheatsheet for the default shortcuts. From this list, I think the ones that should be supported to make i3wm usable are:

  • mod + Enter = open terminal
  • mod + f = full screen
  • mod + e = layout change (default)
  • mod + s = layout change (stacked)
  • mod + w = layout change (tabbed)
  • mod + 0-9 = switch to workspace
  • mod + shift + 0-9 = move window to workspace
  • mod + d = launcher
  • mod + shift + q = kill window
  • mod + shift + r = restart i3 in place
  • mod + shift + e = exit i3

And I have never actually tested in i3wm so it would be a good idea to run toshy-env and see how the environment module identifies the window manager. I suspect it will be 'i3', but I've never actually seen it myself.

❯ toshy-env
(EE) Desktop Environment not in de_names list! Should fix this.
	i3

(EV) Toshy env module sees this environment:
		 DISTRO_ID       = 'fedora'
		 DISTRO_VER      = '40'
		 VARIANT_ID      = 'workstation'
		 SESSION_TYPE    = 'x11'
		 DESKTOP_ENV     = 'i3'
		 DE_MAJ_VER      = 'no_logic_for_DE'

@RedBearAK
Copy link
Owner

@jfernandez

Thanks for the list. Here's the basic idea, and it should work, although I haven't tested it. There may be some awkward aspects of mapping all these technically "Alt+key" shortcuts to your "mod+key" shortcuts, that may throw off some apps that were looking for some of those "Alt+something" shortcuts. But that just means those shortcuts won't work in those apps, because they will be preempted by these more global shortcuts.

I threw in a remap from Cmd+Space to the same launcher shortcut, like I usually try to do, but the physical Super+D should also work as it normally would in i3 without Toshy.

Let me know how it goes. You want to find the "slice marks" in your config file tagged with user_apps, that's a good spot for these kinds of overrides, and within any of the "slice marks" in the config file these lines will be protected from Toshy re-installs and installs from newer versions of the zip file. Make sure you disable the OptSpec Layout like I said earlier.

keymap("User overrides for i3 WM", {

    # The "mod" that is active in the i3 settings is assumed for this keymap to be 
    # the "Super" key code, which the i3 cheatsheet calls "Mod4". So these remaps
    # will output to "Super" shortcuts. 

    # The input shortcuts will be "Alt" or "LA" for "LEFT_ALT" based on user's PC 
    # keyboard type and wanting to use the physical Super key position. 

    C("RC-Space"):              C("Super-D"),                   # Cmd+Space: Launcher
    C("LA-D"):                  C("Super-D"),                   # Mod+D: Launcher
    C("LA-Enter"):              C("Super-Enter"),               # Mod+Enter: Open terminal
    C("LA-F"):                  C("Super-F"),                   # Mod+F: Full screen
    C("LA-E"):                  C("Super-E"),                   # Mod+E: Layout change (default)
    C("LA-S"):                  C("Super-S"),                   # Mod+S: Layout change (stacked)
    C("LA-W"):                  C("Super-W"),                   # Mod+W: Layout change (tabbed)
    C("LA-0"):                  C("Super-0"),                   # Mod+0: Switch to workspace 0
    C("LA-1"):                  C("Super-1"),                   # Mod+1: Switch to workspace 1
    C("LA-2"):                  C("Super-2"),                   # Mod+2: Switch to workspace 2
    C("LA-3"):                  C("Super-3"),                   # Mod+3: Switch to workspace 3
    C("LA-4"):                  C("Super-4"),                   # Mod+4: Switch to workspace 4
    C("LA-5"):                  C("Super-5"),                   # Mod+5: Switch to workspace 5
    C("LA-6"):                  C("Super-6"),                   # Mod+6: Switch to workspace 6
    C("LA-7"):                  C("Super-7"),                   # Mod+7: Switch to workspace 7
    C("LA-8"):                  C("Super-8"),                   # Mod+8: Switch to workspace 8
    C("LA-9"):                  C("Super-9"),                   # Mod+9: Switch to workspace 9
    C("LA-0"):                  C("Super-Shift-0"),             # Mod+Shift+0: Move window to workspace 0
    C("LA-1"):                  C("Super-Shift-1"),             # Mod+Shift+1: Move window to workspace 1
    C("LA-2"):                  C("Super-Shift-2"),             # Mod+Shift+2: Move window to workspace 2
    C("LA-3"):                  C("Super-Shift-3"),             # Mod+Shift+3: Move window to workspace 3
    C("LA-4"):                  C("Super-Shift-4"),             # Mod+Shift+4: Move window to workspace 4
    C("LA-5"):                  C("Super-Shift-5"),             # Mod+Shift+5: Move window to workspace 5
    C("LA-6"):                  C("Super-Shift-6"),             # Mod+Shift+6: Move window to workspace 6
    C("LA-7"):                  C("Super-Shift-7"),             # Mod+Shift+7: Move window to workspace 7
    C("LA-8"):                  C("Super-Shift-8"),             # Mod+Shift+8: Move window to workspace 8
    C("LA-9"):                  C("Super-Shift-9"),             # Mod+Shift+9: Move window to workspace 9
    C("LA-Q"):                  C("Super-Shift-Q"),             # Mod+Shift+Q: Kill window
    C("LA-R"):                  C("Super-Shift-R"),             # Mod+Shift+R: Restart i3 in place
    C("LA-E"):                  C("Super-Shift-E"),             # Mod+Shift+E: Exit i3

}, when = lambda ctx: 
            DESKTOP_ENV == 'i3' and
            KBTYPE == 'Windows' and
            matchProps(not_lst=remotes_lod)(ctx) )

@jfernandez
Copy link
Author

That worked great! You forgot to add the -Shift- Modifier to move window to workspace section and below, but I fixed that in my local copy.

@RedBearAK
Copy link
Owner

RedBearAK commented Jun 18, 2024

Oh, right. On the input side. Forgot to copy-paste in that column.

keymap("User overrides for i3 WM", {

    # The "mod" that is active in the i3 settings is assumed for this keymap to be 
    # the "Super" key code, which the i3 cheatsheet calls "Mod4". So these remaps
    # will output to "Super" shortcuts. 

    # The input shortcuts will be "Alt" or "LA" for "LEFT_ALT" based on user's PC 
    # keyboard type and wanting to use the physical Super key position. 

    C("RC-Space"):              C("Super-D"),                   # Cmd+Space: Launcher
    C("LA-D"):                  C("Super-D"),                   # Mod+D: Launcher
    C("LA-Enter"):              C("Super-Enter"),               # Mod+Enter: Open terminal
    C("LA-F"):                  C("Super-F"),                   # Mod+F: Full screen
    C("LA-E"):                  C("Super-E"),                   # Mod+E: Layout change (default)
    C("LA-S"):                  C("Super-S"),                   # Mod+S: Layout change (stacked)
    C("LA-W"):                  C("Super-W"),                   # Mod+W: Layout change (tabbed)
    C("LA-0"):                  C("Super-0"),                   # Mod+0: Switch to workspace 0
    C("LA-1"):                  C("Super-1"),                   # Mod+1: Switch to workspace 1
    C("LA-2"):                  C("Super-2"),                   # Mod+2: Switch to workspace 2
    C("LA-3"):                  C("Super-3"),                   # Mod+3: Switch to workspace 3
    C("LA-4"):                  C("Super-4"),                   # Mod+4: Switch to workspace 4
    C("LA-5"):                  C("Super-5"),                   # Mod+5: Switch to workspace 5
    C("LA-6"):                  C("Super-6"),                   # Mod+6: Switch to workspace 6
    C("LA-7"):                  C("Super-7"),                   # Mod+7: Switch to workspace 7
    C("LA-8"):                  C("Super-8"),                   # Mod+8: Switch to workspace 8
    C("LA-9"):                  C("Super-9"),                   # Mod+9: Switch to workspace 9
    C("LA-Shift-0"):            C("Super-Shift-0"),             # Mod+Shift+0: Move window to workspace 0
    C("LA-Shift-1"):            C("Super-Shift-1"),             # Mod+Shift+1: Move window to workspace 1
    C("LA-Shift-2"):            C("Super-Shift-2"),             # Mod+Shift+2: Move window to workspace 2
    C("LA-Shift-3"):            C("Super-Shift-3"),             # Mod+Shift+3: Move window to workspace 3
    C("LA-Shift-4"):            C("Super-Shift-4"),             # Mod+Shift+4: Move window to workspace 4
    C("LA-Shift-5"):            C("Super-Shift-5"),             # Mod+Shift+5: Move window to workspace 5
    C("LA-Shift-6"):            C("Super-Shift-6"),             # Mod+Shift+6: Move window to workspace 6
    C("LA-Shift-7"):            C("Super-Shift-7"),             # Mod+Shift+7: Move window to workspace 7
    C("LA-Shift-8"):            C("Super-Shift-8"),             # Mod+Shift+8: Move window to workspace 8
    C("LA-Shift-9"):            C("Super-Shift-9"),             # Mod+Shift+9: Move window to workspace 9
    C("LA-Shift-Q"):            C("Super-Shift-Q"),             # Mod+Shift+Q: Kill window
    C("LA-Shift-R"):            C("Super-Shift-R"),             # Mod+Shift+R: Restart i3 in place
    C("LA-Shift-E"):            C("Super-Shift-E"),             # Mod+Shift+E: Exit i3

}, when = lambda ctx: 
            DESKTOP_ENV == 'i3' and
            KBTYPE == 'Windows' and
            matchProps(not_lst=remotes_lod)(ctx) )

Note that the conditional for the keymap contains the same kind of thing that causes all the modmaps and generally active keymaps to disable themselves as long as you are in a "remote" or virtual machine app window.

matchProps(not_lst=remotes_lod)(ctx)

This should result in the same exact shortcuts working the same way while in one of those apps, since the physical Super key would turn back into a Super key. As long as the i3 shortcuts are not somehow intercepted by the VM or remote app window. That would have nothing to do with Toshy.

It may not make sense to put this in the default Toshy config, since how it's put together kind of depends on what the user chooses as the "mod" key in their i3 config. (Edit: Also depends on the keyboard type for which modifier is used on the input combos.)

You can close this or keep it open in case you have some issues specific to this. If you close it you can re-open the issue yourself.

@RedBearAK RedBearAK changed the title (Question) Running toshy with a tiling window manager (Question) Running toshy with i3 window manager Jun 18, 2024
@jfernandez
Copy link
Author

Thanks @RedBearAK, closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants