# Unicode input under QT/KDE

**URL:** <https://community.keyboard.io/t/unicode-input-under-qt-kde/941>\
**Category:** Programming\
**Created:** [January 12, 2018, 9:53am UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941 "2018-01-12T09:53:20Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamadagni](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/jamadagni/32/2030_2.png) [@jamadagni](https://community.keyboard.io/u/jamadagni)\
**Post date:** [January 12, 2018, 9:53am UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941/1 "2018-01-12T09:53:20Z")

</div>

A propos plugin capabilities:

[https://github.com/keyboardio/Kaleidoscope-Unicode](https://github.com/keyboardio/Kaleidoscope-Unicode) – I wonder if you can confirm it works on Linux/KDE Plasma 5? I am currently using XKB layouts for switching between scripts (Latin and many Indic) that I use. Would be interesting if I could directly use the keyboard’s firmware capabilities for that!

---

<div class="post-metadata">

**Author:** ![algernon](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/algernon/32/4404_2.png) [@algernon](https://community.keyboard.io/u/algernon)\
**Post date:** [January 12, 2018, 10:39am UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941/2 "2018-01-12T10:39:44Z")

</div>

> [@Comparing KeyboardIO M01 and Ergodox EZ](https://community.keyboard.io/t/comparing-keyboardio-m01-and-ergodox-ez/933/6):
>
> I wonder if you can confirm it works on Linux/KDE Plasma 5?

Most likely, yes. It works under GNOME3, can’t see why it wouldn’t with KDE. Behind the scenes, it uses an unicode hex-input thing, so when you input, say `👪`, it sends `Ctrl+Shift+u hexcode SPC` to the host.

---

<div class="post-metadata">

**Author:** ![jamadagni](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/jamadagni/32/2030_2.png) [@jamadagni](https://community.keyboard.io/u/jamadagni)\
**Post date:** [January 12, 2018, 11:01am UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941/3 "2018-01-12T11:01:25Z")

</div>

😔 then it won’t work with Qt/KDE applications: [https://bugs.freedesktop.org/show\_bug.cgi?id=26747](https://bugs.freedesktop.org/show_bug.cgi?id=26747)

---

<div class="post-metadata">

**Author:** ![jamadagni](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/jamadagni/32/2030_2.png) [@jamadagni](https://community.keyboard.io/u/jamadagni)\
**Post date:** [January 12, 2018, 11:05am UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941/4 "2018-01-12T11:05:28Z")

</div>

Would it be possible for the plugin to input the surrogate pairs? That works with Qt/KDE which uses UTF-16 all through.

IIUC from your page on the Focus plugin it is possible for the keyboard to know what is the active window. In that case, it could shift from direct UTF-32 input to UTF-16 if that is possible.

---

<div class="post-metadata">

**Author:** ![jamadagni](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/jamadagni/32/2030_2.png) [@jamadagni](https://community.keyboard.io/u/jamadagni)\
**Post date:** [January 12, 2018, 1:12pm UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941/5 "2018-01-12T13:12:10Z")

</div>

Hmm just realized that that’s not the point at all. If there is no way to input arbitrary codepoints other than sending scancodes, then it doesn’t matter whether it is UTF-32 or UTF-16, it can’t be done.

@algernon @algernon @algernon please pretty please can you look into fixing [this X bug](https://bugs.freedesktop.org/show_bug.cgi?id=26747) like you fixed [the warp one](https://bugs.freedesktop.org/show_bug.cgi?id=99914)? 💐💐💐💐💐💐💐💐💐💐💐💐…1008!

---

<div class="post-metadata">

**Author:** ![james.nvc](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/james.nvc/32/54_2.png) [@james.nvc](https://community.keyboard.io/u/james.nvc)\
**Post date:** [January 12, 2018, 2:44pm UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941/6 "2018-01-12T14:44:23Z")

</div>

It might be slightly easier to write a little program that intercepts the C-S-u key & reads the codepoint…While the normal input works for me most of the time, Emacs intercepts the C-S-u keys, so I taught it how to treat it the same as Gnome: [https://github.com/jamesnvc/dotfiles/blob/master/emacs.d/user.el#L290](https://github.com/jamesnvc/dotfiles/blob/master/emacs.d/user.el#L290). Could probably generalize that with a little daemon process. I’ll have a try implementing that.

---

<div class="post-metadata">

**Author:** ![jamadagni](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/jamadagni/32/2030_2.png) [@jamadagni](https://community.keyboard.io/u/jamadagni)\
**Post date:** [January 12, 2018, 2:48pm UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941/7 "2018-01-12T14:48:48Z")

</div>

🙏🙏🙏 I hope you mean for KDE… I mean something that works on KDE whether it uses the KDE libs or not…

---

<div class="post-metadata">

**Author:** ![james.nvc](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/james.nvc/32/54_2.png) [@james.nvc](https://community.keyboard.io/u/james.nvc)\
**Post date:** [January 12, 2018, 3:29pm UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941/8 "2018-01-12T15:29:14Z")

</div>

Right, make the Gnome-style input work on KDE (since that’s how the Unicode plugin works).

---

<div class="post-metadata">

**Author:** ![algernon](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/algernon/32/4404_2.png) [@algernon](https://community.keyboard.io/u/algernon)\
**Post date:** [January 12, 2018, 3:46pm UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941/9 "2018-01-12T15:46:37Z")

</div>

Well, the warp one was eventually fixed in firmware, the original issue is still present in libinput… 😛

As for doing this in Xorg… I worked with Xorg (then XFree86) code before, not looking forward to do it again. But a small tool that intercepts `C-S-u` should be doable. I’ll see what I can do, but this is going to be pretty low on my todo list for now, I’m afraid, so if anyone else gets there first, so much the better! It shouldn’t be too hard.

---

<div class="post-metadata">

**Author:** ![james.nvc](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/james.nvc/32/54_2.png) [@james.nvc](https://community.keyboard.io/u/james.nvc)\
**Post date:** [January 12, 2018, 7:33pm UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941/10 "2018-01-12T19:33:52Z")

</div>

I have a very hacky solution [here](https://gist.github.com/jamesnvc/5c73446fe46b689450c227305953344c)…it sort of works, but the main problem is that the C-S-u still goes to the underlying application (so, for example, when typing in a terminal, it will delete the line before typing the unicode char).

I’ll try to look into a more complete solution, but I think that will mean actually using Xlib.

---

<div class="post-metadata">

**Author:** ![algernon](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/algernon/32/4404_2.png) [@algernon](https://community.keyboard.io/u/algernon)\
**Post date:** [January 12, 2018, 7:45pm UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941/11 "2018-01-12T19:45:13Z")

</div>

FWIW, there is a daemon linked to in the bug report above, I just updated that to support xdotool3, and it works like a charm so far. Will push it to GitHub in a bit. It will need a little shaking up, because it currently expects `Ctrl+Shift+u` to remain held.

Anyway, quick hack is going up in an hour or two (babies need me now, so will finish later).

---

<div class="post-metadata">

**Author:** ![algernon](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/algernon/32/4404_2.png) [@algernon](https://community.keyboard.io/u/algernon)\
**Post date:** [January 12, 2018, 8:49pm UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941/12 "2018-01-12T20:49:31Z")

</div>

Current code is up on GitHub:

> **[algernon/ucode](https://github.com/algernon/ucode)**
>
> Contribute to algernon/ucode development by creating an account on GitHub.

It doesn’t work with the Unicode plugin yet, but I’ll get there soon. It may have issues, as this is code someone hacked up some 4 years ago as a proof of concept.

Update: I just tested it, and when using the `C-S-u codepoint SPC` sequence by hand, it works. When using it via the Unicode plugin, it does not seem to. Not quite sure why, perhaps some timing issue. May debug later, but patches are - of course - more than welcome. Testing too. 🙂

---

<div class="post-metadata">

**Author:** ![jamadagni](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/jamadagni/32/2030_2.png) [@jamadagni](https://community.keyboard.io/u/jamadagni)\
**Post date:** [January 13, 2018, 2:18am UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941/13 "2018-01-13T02:18:44Z")

</div>

> [@Comparing KeyboardIO M01 and Ergodox EZ](https://community.keyboard.io/t/comparing-keyboardio-m01-and-ergodox-ez/933/5):
>
> Mouse control: M01’s Fn layer right? But is scroll available too?
> 
> Yep, and yep!

Hmmm but:

> [@Possible bug: scrolling on mouse movement](https://community.keyboard.io/t/possible-bug-scrolling-on-mouse-movement/706/5):
>
> We don’t have any wheel actions in the core. There is an open ticket about mouse clicks sometimes be interpreted as click-and-holds.

So again my question: is it possible to emulate scrolling by the M01 firmware alone?

---

<div class="post-metadata">

**Author:** ![jamadagni](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/jamadagni/32/2030_2.png) [@jamadagni](https://community.keyboard.io/u/jamadagni)\
**Post date:** [January 13, 2018, 2:30am UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941/14 "2018-01-13T02:30:52Z")

</div>

Hmm perhaps this Unicode thing should be split out into a separate thread? I sorta got frustrated with the “only so many questions on your first day” else I would have initially started on a separate thread. Can someone do it? Thanks!

---

<div class="post-metadata">

**Author:** ![jamadagni](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/jamadagni/32/2030_2.png) [@jamadagni](https://community.keyboard.io/u/jamadagni)\
**Post date:** [January 13, 2018, 2:46am UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941/15 "2018-01-13T02:46:57Z")

</div>

OK I’m testing on Kubuntu Xenial which has:

libx11-dev:amd64 (2:1.6.3-1ubuntu2) libxdo3:amd64 (1:3.20150503.1-2)

But a few things I’m not clear about:

The code `XKeysymToKeycode(dpy,XK_U)` seems to indicate that U is a necessary part of the input sequence. Yet the [readme](https://github.com/algernon/ucode/blob/master/README) says only:

> 1. Press Ctrl
> 2. Press Shift
> 3. Type the hexadecimal code, e.g. 3b4 for Greek delta δ
> 4. Release Ctrl and Shift

I guess the README needs to be updated (and I’ll send in a pull request once the following problem is solved).

Anyhow, it is not clear whether the `U` should be continuously pressed as well or only `Ctrl` and `Shift`. From [the GNOME official help](https://help.gnome.org/users/gnome-help/stable/tips-specialchars.html.en) and [this SuperUser post](https://superuser.com/a/59419/243023) it only seems as if Ctrl and Shift should be held down. I am assuming the same has been implemented by this applet. So that is what I am trying now,

But I am trying both GTK and Qt apps on my platform: I press `Ctrl Shift U`, release `U` while holding down `Ctrl Shift` and I observe that my current application loses focus i.e. the text cursor disappears. I presume this is the “grab”. Then I input the `3b4` suggested in the README followed by space, but nothing happens except that my application gets back the focus i.e. the text cursor reappears.

I tried prefixing it by `0` but that doesn’t help either. I tried putting it in my autostart and rebooting but no fruit there too. I tried loading from a terminal to see if there are any error messages printed but nothing there either.

I tried on both GTK (Firefox) and Qt (KWrite) applications.

Please advise!

---

<div class="post-metadata">

**Author:** ![james.nvc](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/james.nvc/32/54_2.png) [@james.nvc](https://community.keyboard.io/u/james.nvc)\
**Post date:** [January 13, 2018, 3:38am UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941/16 "2018-01-13T03:38:50Z")

</div>

The sequence seems to be “press Control, press Shift, press U, release Control, Shift, U, type the hex, space”. That works for me, at any rate.

---

<div class="post-metadata">

**Author:** ![jamadagni](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/jamadagni/32/2030_2.png) [@jamadagni](https://community.keyboard.io/u/jamadagni)\
**Post date:** [January 13, 2018, 3:52am UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941/17 "2018-01-13T03:52:02Z")

</div>

Hi what Linux/version are you using? This still doesn’t work for me.

---

<div class="post-metadata">

**Author:** ![james.nvc](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/james.nvc/32/54_2.png) [@james.nvc](https://community.keyboard.io/u/james.nvc)\
**Post date:** [January 13, 2018, 3:23pm UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941/18 "2018-01-13T15:23:39Z")

</div>

Ubuntu 16.04.3 LTS, with i3wm under lightDM. I should clarify that I mean the keysequence is what works for me using the standard Gnome input thing (and is what the Kaleidoscope plugin uses); I haven’t tried the tool algernon linked.

---

<div class="post-metadata">

**Author:** ![algernon](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/algernon/32/4404_2.png) [@algernon](https://community.keyboard.io/u/algernon)\
**Post date:** [January 15, 2018, 10:19am UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941/19 "2018-01-15T10:19:40Z")

</div>

> [@jamadagni](#):
>
> The code XKeysymToKeycode(dpy,XK\_U) seems to indicate that U is a necessary part of the input sequence. Yet the readme says only:

Yeah, I have not touched the readme. The code requires `Ctrl+Shift+U` all held at the same time to trigger the daemon’s functionality. You can release them after, though.

> [@jamadagni](#):
>
> I observe that my current application loses focus i.e. the text cursor disappears.

Yep.

> [@jamadagni](#):
>
> Then I input the 3b4 suggested in the README followed by space, but nothing happens except that my application gets back the focus i.e. the text cursor reappears.

I’ll add some debugging to the tool next time I have some capacity, to help us see what is happening.

---

<div class="post-metadata">

**Author:** ![jamadagni](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/jamadagni/32/2030_2.png) [@jamadagni](https://community.keyboard.io/u/jamadagni)\
**Post date:** [July 27, 2018, 8:58am UTC](https://community.keyboard.io/t/unicode-input-under-qt-kde/941/20 "2018-07-27T08:58:13Z")

</div>

Hi can I ping you on this issue?

[Next page](https://community.keyboard.io/t/unicode-input-under-qt-kde/941.md?page=2)
