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

Shortcuts and Text Inserts on non-English keyboard layouts #362

Open
maqmm opened this issue Oct 8, 2024 · 2 comments
Open

Shortcuts and Text Inserts on non-English keyboard layouts #362

maqmm opened this issue Oct 8, 2024 · 2 comments
Labels

Comments

@maqmm
Copy link

maqmm commented Oct 8, 2024

Hello, @Schneegans! Thank you for this extension, it's incredibly convenient. I use it in my work when there are phrase templates that need to be constantly inserted somewhere, but parts of these phrases differ from case to case, and they can be very conveniently typed through the Fly-Pie menu. (this [Insert Text Item] was one of the motives for choosing kando vs Fly-Pie)

Describe the Bug

I encountered a problem where sometimes the Insert Text Item didn't work and didn't insert text into input fields. After localizing the problem, I realized it was due to the keyboard layout. I'm not sure if this is an unknown issue, but Insert Text, and as it later turned out, all Shortcuts only work on one keyboard layout (English for Insert Text Item) if there are characters that don't belong to both layouts.

I'm a beginner and had no experience with Gnome extensions. After digging around, I couldn't find a comprehensive solution to this problem for your extension.

Problem localization

As I understood, the problem occurs in this method: https://github.com/Schneegans/Fly-Pie/blob/main/src/extension/InputManipulator.js#L117-L165
Looking at the commit history, I made sure that this part is constantly changing, and I couldn't find a quick solution on the internet, without knowing the libraries.
For those who might be solving this Issue, maybe this commit will help you: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/146?commit_id=85284acb000ddc70afcf716b6c198b4b5bf5741e#9c3fb9f985e8fe3198fd8110fb752caeb5ef498c

I understand how busy you are with kando, this Issue is more for those who will encounter this.

Workaround

I'll leave here a small solution that helped in my case:

I have two layouts: English (United States) and Russian (Russian Federation). I added the following line to the file src/extension/ClipboardManager.js:

      this._input.activateAccelerator('<Primary>Cyrillic_em');
As a result, it turned out approximately like this:

Both hotkeys are set, but only one works on one of the keyboard layouts.

  // Finally, simulate Ctrl+V.
  GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
    this._input.activateAccelerator('<Primary>v');
    this._input.activateAccelerator('<Primary>Cyrillic_em');
    return GLib.SOURCE_REMOVE;
  });

Important

This only fixes Insert Text and only for the Cyrillic layout.
You can also try to look for the button name, that you need with your layout in the file src/extension/keysyms.js

System

  • Linux distribution: Ubuntu 24.04.1 LTS
  • Fly-Pie version: Fly-Pie 27
  • GNOME Shell version: GNOME Shell 46.0
  • Windowing System: (I try on both) X11 and Wayland
@maqmm maqmm added the bug label Oct 8, 2024
@Schneegans
Copy link
Owner

Thanks for this detailed report! Spontaneously, I see no obvious way to figure out which key combination will paste the clipboard contents automatically. Maybe the best way would be to make this configurable for the user.

That being said, I just added a similar "Paste-Text" action to Kando's main branch. There's a subtle difference in that Kando issues the keyboard shortcuts using key codes as opposed to key values as it is done in Fly-Pie.

So if possible, it would be cool if you could run Kando from source and check if it works there...

@maqmm
Copy link
Author

maqmm commented Oct 14, 2024

I agree with the idea of ​​making the insertion hotkey customizable by the user, I see this as the simplest way.

Thanks for the advice! I launched kando from sources, it works fine on both keyboard layouts. I’ll soon move to it, so far the elements displaying running applications are holding up me a little, but kando looks more promising due to its cross-platform nature.

To implement my tasks, I use a small script that can collect ready-made menus with text insertion, summing up the text of the parent menus and some features. I added the default kando format to it and left Fly-Pie with a flag, uploaded to GH. If anyone needs it, here's the repository.

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

No branches or pull requests

2 participants