Learn through the super-clean Baeldung Pro experience:
>> Membership and Baeldung Pro.
No ads, dark-mode and 6 months free of IntelliJ Idea Ultimate to start with.
Last updated: March 18, 2024
Linux offers different ways to use embedded emojis along with the text.
In this tutorial, we’ll explore various ways to insert an emoji when using Ubuntu and the GNOME desktop environment.
First, we’ll discuss the GNOME Characters application. Following that, we turn to the GNOME Emoji Selector extension. After that, we’ll insert emojis using the Ubuntu terminal and Unicode. Lastly, we’ll look at the use of emojis via the emoji keyboard.
The first approach we’ll learn to use emojis in text is the GNOME Characters application. It provides emojis and related characters by category organized in a basic interface.
Since it may not be available by default on Ubuntu, we’ll install GNOME Characters using apt:
$ sudo apt install gnome-characters
Once the installation is complete, we’ll open the Characters application:
Now, we can view all the emoji characters:
To insert the character into a text, we click on the character to open a dialogue box. After that, we click the Copy Character button:
Lastly, we can paste the character:
This way, we can add emojis to any text field or terminal.
One approach to using emoji in a text editor is the Emoji Picker extension. After the Ubuntu 18.04 LTS release, we can employ this method within GTK text editors. In addition, this emoji selector is also a part of the GNOME environment.
For this method, we open the gedit text editor and right-click within the text field:
After that, we click Insert Emoji from the context menu. Consequently, we get the pop-up from which we can choose any emoji:
On top of the simple selection, the extension offers a range of useful functions:
However, the Emoji Picker extension wouldn’t work on non-GTK applications such as LibreOffice or Firefox.
Of course, one way to insert emojis into a text file is to use the terminal. For this approach, we use a command like echo or printf:
$ echo -e '\U1F604'
In the above code, we use the -e option with echo to enable the interpretation of escape sequences. In addition, we add the Unicode character for the emoji we want to insert.
By redirecting the output of this command, we can add the emoji combined with text:
$ echo -e "Hello World \U1F604" >> emoji_text.txt
Lastly, let’s view the resulting file using the cat command:
$ cat emoji_text.txt
Hello World 🙂
Thus, we can insert emojis into a text via the Ubuntu terminal and escape sequences as long as we know the exact code of the emoji.
We can also set up an emoji keyboard to type emojis seamlessly. This approach is usually quicker, easier, and more convenient to use when compared to previously discussed approaches. However, it takes more time to set up.
In addition, the emoji keyboard, uniemoji, works in all text editors and applications, including LibreOffice.
First, we’ll install the IBus framework for the emoji keyboard:
$ sudo apt install ibus
ibus has different modules for different languages. For emoticons, we’ll work with uniemoji.
Then, we’ll add the universe repository to our system’s list of packages and update the system packages:
$ sudo add-apt-repository universe && sudo apt update
Next, we’ll install two packages, git and make:
$ sudo apt install git make
After that, we’ll fetch the uniemoji repository:
$ git clone https://github.com/salty-horse/ibus-uniemoji.git
Next, we’ll switch the directory using the cd command, and compile the software from the ibus-uniemoji project:
$ cd ibus-uniemoji
$ sudo make install
Lastly, we’ll restart the ibus service:
$ ibus restart
Once we’ve restarted the ibus service, we’ll also restart the system to ensure that the ibus-uniemoji is fully integrated.
Now that we’ve set up the ibus framework, we need to integrate the uniemoji package into the system. For this step, we’ll open Settings from the terminal:
$ gnome-control-center
This opens Settings. Now, we’ll add uniemoji:
Finally, we can insert emojis in any text field and terminal:
Crucially, we’ll have to switch the keyboard by pressing the Command or Windows + Space keys.
In this article, we discussed various ways to insert emojis into a text in Ubuntu.
First, we discussed GNOME Characters to insert emojis. After that, we saw how to add emojis using the Emoji Picker. We also looked at using the Ubuntu terminal to add emojis to files. Lastly, we set up the emoji keyboard to seamlessly insert the emojis.