Schneegans / Fly-Pie

:pie: Fly-Pie is an innovative marking menu written as a GNOME Shell extension.
http://schneegans.github.io/news/2021/12/02/flypie10
MIT License
1.21k stars 26 forks source link

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

Open maqmm opened 2 weeks ago

maqmm commented 2 weeks ago
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('v'); this._input.activateAccelerator('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

Schneegans commented 2 weeks ago

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 commented 1 week ago

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.