Emotional about X11: I'm creating a pure X11 “emoji keyboard”
github.com
github.com
user perspective: As far as I know, it's the only tool offering somewhat reliable emoji input using faked X11 keyboard events. "x11-emoji-picker" comes close, but delegates faking events to "xdotool", with weird consequences like having to restart it to direct emojis to a different window ;)
hacker perspective: It directly integrates xcb in a different event loop (here based on pselect()) and actually works – xcb is IMHO pretty great except for pretty much enforcing its own async model, internally using poll() and reading from the X server into buffers at many occassions, hidden from the consumer. If all your app does is communicate with the X server, you just happily use xcb's model. As soon as you need different things (e.g. local timers), you have a problem. The typical way to address that is dedicating another thread to xcb (AFAIK also done that way by toolkits offering an X11 backend). I hated that idea enough to be stubborn about doing it directly in my main thread, and with quite some trial-and-error, finally succeeded.
Even for those emojis consisting of a singe codepoint, it would really miss the point. There are LOTS of emojis available, an emoji keyboard (or emoji picker) shows them organized in groups and allows searching for them.
but i agree that compose is not a great user experience
I use the compose key as an abbreviation expander among other things. So far this works fine in all applications.
Though I don’t know if we’re talking about something beyond typing the XCompose sequence on the keyboard. If we’re talking about sending programmatic keypresses to applications like in this submission then I don’t know.
Not true even if some broken toolkits impose that limitation.
Still, in practice, it will only work with some applications...
but yeah, no search. but also no extra windows. when i asked i assumed compose + something like an IME could solve both with the search/window being optional.
Of course you can do a lot of things with "input methods" (like popping up some "picker" only when wanted). But then you'll depend on X clients being aware of them in some way, e.g. by implementing the XIM protocol. Lots of applications have that (even xterm), so it might be what you prefer and that's fine. My method with faked key press events is definitely hacky, but will work with any X client, that's the point of it ;)
Not correct. For example, on my usual keyboard layouts¹, I use sequences starting with <dead_A> and <dead_U> for superscripts and subscripts.
> and resulting in a single X key-symbol
Also not correct. I certainly have a few non-single-keysim entries in my .Xcompose, e.g. <Multi_key> <R> <2> ↦ ℝ².
¹ https://github.com/datatravelandexperiments/kps-keyboard-lay...
Implementation is beyond my ability, but if en-US locale were to finally adopt IME, I think it should be semi-trivial to include an optional dictionary file trained with emoji :tofu_on_fire: notation.
¯\_(ツ)_/¯
(or, as it's spelled through my .XCompose, shift-altgr 3 3)
I think there was a time when compose sequences could only emit a single character, at least in some contexts. But as far as i can tell, every text box in every app on my machine supports multi-character sequences.
One of the major flaws in X11 is its poorly designed keyboard input system. When a key is pressed, the keypress event sends a "keycode" - an 8-bit number that references the current layout. This means you're limited to injecting characters that are present in the current layout.
The implications of this design are frustrating. For instance, if you're connecting to a remote system via VNC and the client and server have different keyboard layouts, you'll run into all sorts of issues. Similarly, how do you create an on-screen keyboard that can inject keypresses for characters not available in the current layout? And what if you want to programmatically send some text, but the user has the wrong layout active? It's a mess.
I guess because of this in Debian most of characters in on-screen keyboard didn't work (they "fixed" it by showing only characters present in active layouts instead of fixing the root issue).
The common workaround for this is an ugly hack: you modify the keyboard layout, find unused spots, add desired characters, send key press event and restore the keyboard layout back. See the code: [2]
Also, Wayland which was supposed to get rid of legacy problems, seems to have inherited this ugly design. Also, there seem to be no sane API for managing layouts or switching them programatically, or subscribing to layout change event. Also, you cannot use modifiers like Ctrl to switch layouts because then combinations like Ctrl + C stop working. Keyboard APIs on Linux are broken in the worst way possible since beginning, probably because most developers use only ASCII and do not have experience using multiple layouts.
A better idea would be to allow to send arbitrary Unicode strings and maybe integrate regular input and IME input (input system for typing Asian characters).
[1] https://www.x.org/releases/X11R7.6/doc/xproto/x11protocol.ht...
[2] https://github.com/Zirias/xmoji/blob/master/src/bin/xmoji/ke...
X11 has XkbMapNotify/XkbStateNotify.
Wayland has a wl_keyboard.keymap event.
> A better idea would be to allow to send arbitrary Unicode strings and maybe integrate regular input and IME input (input system for typing Asian characters).
Not particularly, the difficulty here is that some clients want text input, and some clients really do want key events (e.g. think games where holding W does not really have much to do with the Unicode code point 'w'). This was discussed for a long time, and the current design was decided as the best option.
IME systems do exist and already work just fine; they are integrated client-side. IME systems cannot really be integrated into the protocol since many of them involve custom UI.
That said, there's a proposal for an "input-method" extension which lets you commit text directly, but I don't think anybody is actively championing it. https://gitlab.freedesktop.org/wayland/wayland-protocols/-/b...
I understand this point. For this case it makes sense to send both key code (what character does the key map in Latin layout) and translated code (which characters will be printed when key is pressed in current layout). It seems an easier solution than broadcast large structures to every client and let them have each own implementation for translating codes.
Regarding IME, I meant not integrating IME client into a Wayland server but instead unify the API and events that IME uses to insert text with API and events used to notify about regular keypresses.
Yes, it seems I missed XkbStateNotify and XkbLockGroup that can be used to switch layouts (which X11 calls "groups").
I hit all those Wayland issues while working on Squeekboard. https://gitlab.gnome.org/World/Phosh/squeekboard
> Similarly, how do you create an on-screen keyboard that can inject keypresses for characters not available in the current layout?
I switched the keyboard layout on the fly, on key press, if needed. That works... mostly. Chromium and Chromium-based apps know better what layout I am using, so they will misinterpret some inputs despite having a key map already. And then you realize that you can't use a physical keyboard at the same time, because key maps go out of sync while keys are pressed on both. I talked to a Wayland dev about having separate keyboards with separate layouts, but the answer was basically "it's an incompatible change, and it's too late to fix this" (it was in an issue tracker, but no link). So the only way to have a non-input-method on-screen keyboard is to limit yourself artificially to the current layout. Which, of course, is an oft requested feature I will never implement.
> A better idea would be to allow to send arbitrary Unicode strings and maybe integrate regular input and IME input (input system for typing Asian characters).
Isn't Mac OS do something like that? I agree this is the way to go. But the stumbling block is - again - that applications like Chromium won't implement this. I created the text-input-v3 protocol some 4 years ago, and it's still basically only used in GNOME.
But with new funding from NLNet I'm gathering a special ops team to push input methods again this year :)
> most developers use only ASCII and do not have experience using multiple layouts.
I'm getting that impression as well after discussing the topic of internationalization on Mastodon: using languages other than English is undervalued by open source devs. I mean, how often do you find variables named in Spanish or Russian in open source software? It's a very anglocentric bubble.
And that's a good thing.
You can't randomly mix languages in source code, and any other choice of common language than english would exclude a LOT more people from the project.
All of this isn't related to i18n/l10n of your application at all. People not knowing english is a much more relevant factor when talking about user interfaces. I actually plan to localize my Xmoji tool eventually, it's just postponed until more important stuff is done (I mean, I assume most people would get together enough english to be able to use an emoji keyboard after all, but of course, especially seaching would benefit from l10n).
Still, an anglocentric bubble diminishes internationalization, and I disagree that it's a good thing.
> Also, there seem to be no sane API for managing layouts or switching > them programatically
Layouts only exist as "data" as far as the X server is concerned, clients must fetch them and map themselves from the key codes. Libraries like xkbcommon (or even grandfather Xlib) do the job for you. That said, there are APIs to modify the mapping (by publishing messages/events) as you wish. The ugliness is, apart from the fact that you're forced to fiddle with the mapping at all, that you can't guarantee another client will process everything in sequence. It might apply a new mapping before processing all its queued key press events. That's why my code adds delays between fiddling with the mapping and sending the events.
Yes, it's extremely ugly. Still, at least for me, it works. Try it out ;)
And yes, Windows is doing better here, there's a Unicode-flavor of keyboard events available.
edit: It does, libinput exposes keyboard events via evdev.
https://www.youtube.com/watch?v=lIFE7h3m40U
It's funny at the end he says "and don't ever suggest me I use Linux, just don't." I felt he expected it to be really hard project on Linux, while iterally his project is a single keyboard layout file.
On Gnome there is the "Characters" application which is pretty handy. I do want to make a few improvement to search, but otherwise it's pretty good. You copy the unicode character to the clipboard and can then paste it wherever you need.
If you run Gnome it's probably already installed. If not: https://gitlab.gnome.org/GNOME/gnome-characters
Seems really well done, and most importantly the search works well and it has "recents". I do wish it wouldn't automatically close itself after clicking/copying an emoji, but I try not to let perfect be the enemy of good :-)
Nevertheless, it looks like a pretty cool tool!
I'd wager that once I get hardware made in 2024, Wayland may work well for me (though in its defense it does work fine on my one machine with an Intel integraded GPU), but for now none of my (very old) discrete GPUs work reliably with Wayland, with 2 GPUs and 3 drivers (nvidia vs nouveau for my old GeForce and "radeon" (not amdgpu) for my old AMD card) causing 3 symptoms:
1. Crashes immediately on login
2. Black Screen
3. Kind-of sort-of works, but sometimes the screen just freezes for no reason and sometimes switching VTs fixes it sometimes not.
OpenBSD Xenocara
Strictly speaking Linux is "productive and usable" with nothing but a terminal multiplexer and a shell to work with. With expectations as high as they are in 2024, I don't think former Windows or Mac users will feel at-home with an x11 session. Switching away from bazaar-style software development is a prerequisite for the Year of the Linux Desktop.
Bazaar-style software development is the sole advantage free desktop has over macOS and Windows.
"sole advantage" isn't correct either - there's a plethora of reasons to use Linux. In the enterprise, people pay companies money to keep their Linux away from bazaar-level patches and randomly packaged repos. More casually, a lot of people don't use desktop Linux for a particularly advanced purpose and just treat it like a Mac/Windows/Chrome machine with fewer advertisements. Some people do very much get a lot of value out of the bazaar-side of Linux, but the comparison between the two styles wouldn't exist at all if Linux didn't entertain both philosophies.
[1]: https://qa.debian.org/popcon-graph.php?packages=xserver-xorg...
[2]: https://qa.debian.org/popcon-graph.php?packages=libwayland-s...
Made me think of the emoji physical keyboard from Tom Scott https://youtu.be/3AtBE9BOvvk
- Text input with large character sets (Extended TRON Code)
- Text input with small character sets (the application program can select which one (although it is not guaranteed to be available, unless the user installs an appropriate keyboard layout); e.g. APL character set)
- Command mode
- Game mode
- Hybrid mode
This way it can handle IME as well, and also specialized layouts for purposes (such as APL programming), and can handle nearly raw keyboard events when desired (although, for purposes of security and others, some combinations might still be handled by the operating system or by the window manager).
A few years ago I wrote https://gitlab.com/finnoleary/zhmenu (excuse the deadname in the URL there). I'm reasonably sure it partially counts? I'd meant to build an emoji database for it but never got around to it.
Apart from that, use X11 as long as you wish!
I'm just glad we can finally improve the open source desktop-environment infrastructure to match those of Windows and macOS: we've been stuck for too long.
"was" sure. "still is" it depends on your use case.
for me Wayland overtook X11 as superior in the last year.
This is not a problem of X11 itself.
Maybe a years or two until Wayland gets to full feature parity (except for features Wayland specifically does not have like network support and drawing window borders etc.)
In those same two year I expect all app I use to be running native on Wayland as well. (IntelliJ being the main app I'm waiting for and they are making progress)
That's a feature, not a security issue.
Any closed source app could easily contain a keylogger: great feature!
If we want people to run closed source on Linux, we need facilities to sandbox these apps like on other OSes. Flatpak is moving in this direction. Wayland's security also helps.
I think I did managed to wrangle fcitx into some reasonable emoji input in the past but at some point it broke / I lost it and configuring that tool is just an unpredictable mess...
Will keep an eye on yours!
Sending fake key events is unfortunately "hacky". You need to temporarily switch the keyboard mapping, and many X applications have races between applying a new mapping and processing key press events, that's why I added (now configurable, new release soon) delays... and also, I found applications (e.g. chromium) having issues to correctly combine ZWJ sequences from individual key events, so I added more "hacks" to help with that, also just made configurable.
To sidestep these issues, my tool also offers transfer via "primary selection": Just middle-click an emoji to select it, and middle-click again where you want to insert it. Downside: Two clicks instead of just one.
cat ~/.local/share/emojis/emojis| wofi -i -d -M fuzzy -H 700 | cut -d " " -f 1 | tr -d '\040\011\012\015' | wtype -
It shows an overlay fuzzy-searchable list of all emojis, and it writes selected one to the input regardless of the toolkit. assign it to a keyboard shortcut and you're good to go.the ~/.local/share/emojis/emojis file is just a list of all emojis:
cat ~/.local/share/emojis/emojis | head -n 3
Grinning Face
Grinning Face with Big Eyes
Grinning Face with Smiling Eyes
(HN is removing the emojis but each line starts with the emoji self, followed by the description)During COVID, people were using a golf club as a substitute for a cotton swab.
We now have generative AI that can make any desired emoticon you can dream of, except you can't use it because of Unicode.
The worst part is Unicode breaking existing documents by retroactively converting some common symbols emoji-default, despite supposed stability guarantees.
The second worst part is the emoji combining sequences becoming an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.
That was the main reason for me to pull in harfbuzz. At least it "just resolves" those sequences to glyph indices.
[1] Consider if your vector image representing a soldering iron is someone’s IP, and they rescind licensing for use/redistribution of it. Poof goes all the (legal) copies of your emoji, leaving future historians scratching their heads about what was supposed to be there in the text, and what meaning it contributed. (A concrete case of this actually happening — though not with vector images, but rather stock sound effects: https://roblox.fandom.com/wiki/Roblox_death_sound)
What they should have done is to just have two characters <START_EMOTICON> and <END_EMOTICON>. And you could have text like:
I'm not doing it <START_EMOTICON>pouting<END_EMOTICON>
If the renderer supports the "pouting" emoji it would replace the text and if it doesn't it would just render: I'm not doing it *pouting*
Everyone would be free to create emojis. You could pick your own emoji provider. So if the emoji doesn't exist locally it would be fetched from `http://emojiprovider.tld/pouting`. If you don't like it you can install another one.It's ridiculous that there's no "pouting" emoji but there 6 emojis for pregnant men.
[1]: Yes, they're called emoticons in Unicode, not emojis. The term emoji entered English later.
What do you mean ?
Adding skin tone modifiers to emojis was a bit odd to me, since I view them as signifying emotions rather than people. Maybe that's why, of the six Fitzpatrick scale[0] skin tones they drew from, the only one not added was mine.
Similarly odd to me (to the point of appearing performative) was having a male/female/ambiguous variant on every job emoji and a separate option for every two-child two-parent family "gender" permutation. That's not how I view language as working, particularly because you're not going to be able to cover all valid families that way. It makes more sense to me, if communication rather than tokenism is the goal, to have a couple of representative emojis that convey the general concept, and then specify whatever you want about the relevant people afterward.
In fact the emoji committee backpedaled on family permutations for exactly this reason, and now recommends (exactly as you suggest) "symbolic" family glyphs and juxtaposition of existing people-emoji to describe families in detail.
You can read about it here: https://www.unicode.org/L2/L2022/22276-family-emoji-guidelin...
1. Two people without children
2. Two people with children.
The former being short for "just the parents" or childless couples and the latter encompassing all families with kids regardless of the numbers. This is a compromise answer, but I think it serves the purpose best given the intended use of emojis.
And even better solution would be to figure out some iconography that would denote "family" without explicitly depicting the people, but I'm at a loss on that one. I mean the people are what families are all about, it's hard to divorce the concept.