Quick pop-up emoji input on Linux [updated]
<update> I’ve since rolled my own solution, which I prefer and recommend over this one. Check it out! Splatmoji. <update>
I need pop-up Linux emoji input that doesn’t require a mouse. Something like Emoji Keyboard or EmojiOne Picker require the hands to leave the keyboard and click on an emoji – this is a bunch better than jumping into a web browser and looking one up, but still. Yuck.
The solution I finally found is ibus-uniemoji. Ibus is a framework on Unix that is most generally used for input of foreign characters from a standard keyboard, e.g. pinyin, Russian, or in this case, emoji. Uniemoji uses this to provide an easy pop-up for emoji selection by name or keyword. No mouse!
Ensure the ibus daemon is running at startup, or whenever suits you:
1 |
ibus-daemon -drx |
It’s not in the Ubuntu repos as of writing, so to install:
1 2 3 4 |
git clone https://github.com/salty-horse/ibus-uniemoji /tmp/uniemoji cd /tmp/uniemoji sudo make install ibus restart |
Here is the script I wrote to toggle between normal input and emoji input:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
#!/usr/bin/env python3 # Given a list of possible ibus engines to cycle through as args, will cycle # through them. If current engine is not in the list, will select the first # from the args. def main(): """ main """ import os import sys import subprocess engines = sys.argv[1::] if not engines: print('No engines given - nothing to do', file=sys.stderr) sys.exit(1) engine_current = subprocess.getoutput('ibus engine') curr_idx = engines.index(engine_current) next_idx = (curr_idx + 1) % len(engines) cmd = [ 'ibus', 'engine', engines[next_idx], ] subprocess.run(cmd, check=True) cmd = [ 'notify-send', 'Swtiched ibus engine to "{}"'.format(engines[next_idx]), ] subprocess.run(cmd) if __name__ == '__main__': main() |
And finally to toggle between (or cycle across) an arbitrary number of ibus engines, find the engines you want by running ibus list-engine
and call the script like this from some key combination (see your X or window manager config, whatever):
1 |
ibus-switch.py engine1 engine2 |
In my case, I bound this via my i3 config:
1 |
ibus-swtich.py xkb:us::eng uniemoji && bash $HOME/.xsession |
Note: you may, like me, need to re-establish your X keyboard settings after each time you switch ibus engines or else you’ll lose your compose keys, maps, etc. To ensure this I just re-run my .xsession as above.
?