mkiol / dsnote

Speech Note Linux app. Note taking, reading and translating with offline Speech to Text, Text to Speech and Machine translation.
Mozilla Public License 2.0
589 stars 20 forks source link

Special keys apparently not supported #152

Closed Moini closed 3 months ago

Moini commented 3 months ago

Hi - my keyboard has a couple special keys that I would like to be able to use to quickly access SpeechNote's functionality.

Specifically, those are:

XF86Calculator XF86Home XF86Mail

They do not seem to be used by my OS (Linux Mint), so theoretically, they should be working, but they are not. I suspect that maybe SpeechNote does not support those special keys?

mkiol commented 3 months ago

Hi. Thanks for the report.

Did you try to just set key shortcut to "Calculator", "Home Page" or "Launch Mail"?

Speech Note uses Qt abstractions to handle these key events. Valid names accepted by Qt are listed here. The name of the shortcut should be the same as in this list (including spaces). Additionally, it looks like these names are translated, so if your language on the system is not English, you should use the translated version. I know, it's a bit complicated and weird at the same time :)

Also make sure that key binding is not already configured for something else. For instance, my keyboard has "Media Stop" key. To make it work I had to remove KDE Plasma default shortcut for stopping media.

For example: image

Moini commented 3 months ago

Mmh, thank you, @mkiol - using Linux Mint with Xfce here.

When I press the default shortcuts (and have them set in the settings), a red microphone symbol appears in my notification area and recording works, but nothing happens when I use 'Calculator' or 'Taschenrechner' (which should be the correct translation to German, but I didn't know where to find the Qt translation files - looked for them, but nothing came up on their Github, or in their Wiki. Maybe they don't have any...).

I do have Input Remapper installed already anyway ... that should do the trick, too.

It would be nice to be able to just press the key while the entry field is active to set it as the new shortcut.

mkiol commented 3 months ago

I think I found where is the problem.

So, there are actually two steps of "translations":

  1. from text you provide in the widget to Qt key code (done in Qt lib)
  2. from Qt key code to X11 key code (done in QHotkey lib that I'm using in Speech Note to register global key bindings)

The first one works fine. When "Calculator" or "Launch Mail" is specified, the key code is correct, but the problem occurs in the second case. It seems that QHotkey only supports a very limited number of XF86 keys. Fortunately, I'm building the QHotkey library from sources in Speech Note, so I think I can patch it and extend this list to other keys as well, such as XF86Calculator and others.

I will try to implement this in the next release.

Thanks for finding this interesting problem. I learned something new :)

Moini commented 3 months ago

Sounds good, thank you, @mkiol !

Do you know where users need to look to find the correct strings for their own language? E.g. I'm not at all sure what someone would translate 'Home Page' to, or 'Launch Email'. I could try out multiple things that come to mind, but being able to look it up in some po/ts/... file would be much faster... (and if that were mentioned in a tooltip somewhere in the software, that would be the most helpful way).

mkiol commented 3 months ago

I did a deeper investigation and fortunately, both English and translated names are supported in Qt. You can set "Launch Mail" or "Mail starten" and both are converted to the same key code "Qt::Key_LaunchMail". The problem of finding the right translation is no longer relevant. Good!

Fix for supporting XFree86 keys: 4fff44e88cf707d8ca81ecf4d02191867b2854c1. Will be included in the next release.

Moini commented 3 months ago

Cool, thank you, @mkiol ! Lots of detective work here ...

mkiol commented 3 months ago

The fix is included in the latest v4.6.1 release.

Following XFree86 keys are supported:

X11 key code Shortcut name
XF86Back Back
XF86Forward Forward
XF86Stop Stop
XF86Refresh Refresh
Favorites Favorites
XF86OpenURL Open URL
XF86HomePage Home Page
XF86Search Search
XF86Mail Launch Mail
XF86Memo Memo
XF86History History
XF86AddFavorite Add Favorite
XF86HotLinks Hot Links
XF86Calculator Calculator
XF86Documents Documents
XF86Tools Tools
XF86Pictures Pictures
XF86Music Music
XF86Option Option
XF86Display Display
XF86Launch0 Launch (0)
XF86Launch1 Launch (1)
XF86Launch2 Launch (2)
XF86Launch3 Launch (3)
XF86Launch4 Launch (4)
XF86Launch5 Launch (5)
XF86Launch6 Launch (6)
XF86Launch7 Launch (7)
XF86Launch8 Launch (8)
XF86Launch9 Launch (9)
XF86LaunchA Launch (A)
XF86LaunchB Launch (B)
XF86LaunchC Launch (C)
XF86LaunchD Launch (D)
XF86LaunchE Launch (E)
XF86LaunchF Launch (F)
Moini commented 3 months ago

Thank you, just tested it with the English terms, and they work! :D