artemsen / swaykbdd

Keyboard layout switcher for Sway
MIT License
72 stars 5 forks source link

Proposal to treat empty workspaces as distinct windows for language layout #11

Closed pavelxdd closed 6 months ago

pavelxdd commented 6 months ago

Hello. I have a proposal to treat empty workspaces as distinct windows for language layout.

Current Behavior: 1) Open a text editor in an empty workspace. 2) Switch to a non-English layout and type some text. 3) Close the text editor, leaving the workspace empty. 4) The keyboard layout remains the same as it was in the text editor. 5) Opening a launcher (like bemenu, fuzzel, or wmenu) and trying to enter a command results in text in the non-English layout, necessitating an extra layout switch.

Proposed Change:

Store the keyboard layout for an empty workspace separately. When a window in a workspace is closed, leaving the workspace empty, the keyboard layout would automatically revert to a default layout (e.g., English). This would streamline the user experience, especially when using launchers or command prompts in empty workspaces.

I believe this enhancement would improve the usability of sway in multi-layout environments.

Looking forward to hearing your thoughts.

Thank you for your consideration.

artemsen commented 6 months ago

Fixed! The keyboard layout is now restored to default after closing the window.

pavelxdd commented 6 months ago

That was fast! Thanks, it works as expected.

pavelxdd commented 6 months ago

@artemsen actually it only works on window close events. But if I have a window in a sway scratchpad (a text editor or terminal) and show/hide it by hotkey, then the language layout doesn't change to default when scratchpad is hidden.

Also, when switching from text editor to another empty workspace, the language layout doesn't change as well.

Is there a simple solution to solve these two issues?

artemsen commented 6 months ago

Currently the swaykbdd handles a few number of events: changing keyboard layout, changing focus and closing window. It knows nothing about a scratchpad with its show/hide operation. Actually I don't know what it is either, so I can't help you here. But you are welcome to create a pull request with implementation of this feature =)

pavelxdd commented 6 months ago

Never mind. I've prepended my launcher hotkey with input type:keyboard xkb_switch_layout 0 to always start it with default layout.