How to have text expansion in Fedora with Wayland?

I’ve been looking to have text expansion in my Wayland session in Fedora 34 Silverblue. There are some projects that provide this featue but all of them only work in x.Org.

Is there a way to have this feature in Wayland right now?

Are there plans to integrate text expansion on the SO, like we have in macOS where you can set your own text expansions in settings?

Hi Adrian and welcome!

I have never heard of “text expansion” and am a little confused.

Is this what you mean by “text expansion”? Or do you literally mean making text bigger?

My fault, I thought this was a common enough term. Is similar to what you linked. In macOS you can configure this kind of text substitutions like that if you type “ty” and press space, the OS substitutes what you typed by “thank you”. From System preferences > keyboard > text, you can add as much of these text substitutions as you like.

For xOrg we have software like espanso, which allows the simple substitution that macOS provides and also many other cool features that are more complex. I have failed to find a way to do this in Wayland.

I hope to have made myself clearer, and sorry for not being more explicit in my initial post!

1 Like

Ah, ok.

That would be very tricky with wayland, and I can’t find anything else on it. It looks like the developers of espanso are looking into it if you did not already know. I wish you luck.

1 Like

The expansion of ty to thank you under both X and Wayland can be accomplished with the following steps:

Enable more than one IBus engines “Input Sources” by going into Settings > Region & Language ( gnome-control-center region), as explained in the IBus 1.5.21 release announcement (October 2019).

Designate a Compose Key of your choice by going into Settings > Keyboard Shortcuts (gnome-control-center keyboard) and clicking Alternate Characters Key.

Create a file ~/.XCompose with the following contents:

<Multi_key> <t> <y>                  : "thank you"

A restart of the ibus daemon is necessary to pickup any changes to your ~/.XCompose file:

$ ibus restart

Then, in an application like gedit or Gnome Terminal, type your chosen Compose Key followed by ty. You should see it expanded to thank you.

054c7d6576bdb5f21b5fbb70681ce51b0509b351.gif

For more about this approach of using the Compose key for multicharacter replacements, see this discussion at the Unix & Linux Stackexchange.

Unfortunately, this Compose Key approach won’t work for dynamic content like entering the current date. I’d love to see an ibus-based mechanism with support for dynamic content. I heard that the ibus-libpinyin input method has this ability, but I don’t wish to switch to a different language to attain this goal. In the mean time, to insert dynamic content, I create bash scripts that generate the content and pipe them to the clipboard using xclip -sel c. I execute such bash scripts using Gnome’s Alt+F2 dialog, which is made more useable with the gnome-shell-extension-historymanager-prefix-search extension.

3 Likes

Wow, great answer, didn’t think about using the compose key for this. And even more, it would be kind of easy to make a GUI interface to set up this kind of shortcuts for non technical users.

I think it would be awesome if Fedora got up to speed with macOS in this feature, but I also think that this should be doable tinkering with input methods as you said. If anyone knows of a project that is experimenting in this direction, I would love to know about it.

Text substitution in macOS goes further in that it doesn’t need you to know about the compose key and that it even autocorrects common typos, and power users coming from those lands would greatly appreciate a similarly easy to use and configure solution.

Thanks for your help!

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.