‹ back home

Extended usages of the primary selection

2024-01-06 #desktop #idea #linux #selection #wayland #xorg

When some text is selected, it becomes the primary selection. Other applications can then access this primary selection. The most common usage is to paste it by middle clicking elsewhere, but that’s really the full extent of the interactions that are currently available1.

There is a lot of unexplored potential in this feature. For example, it is perfectly feasible to have some desktop-wide special menu with actions that apply on it. This menu could be opened with Ctrl+RightClick, or maybe Ctrl+Alt+M and could have entries such as:

Implementing such features is pretty feasible and doesn’t require any new architectural changes or modifications to existing compositors. An early prototype could map a global hotkey directly to an action, for example Super+D to open a given word in a dictionary, or Super+R to read the selection out load with an existing text-to-speech engine.

This idea has been floating in my head for a long time, but I haven’t had the opportunity to experiment with it. Specifically, I am not familiar with any desktop dictionary or desktop translation application which I can be executed programmatically. E.g.: it should be possible for a script to execute the application and provide some input text (the current primary selection) programmatically.


  1. This applies to most Unix-like desktops, including Linux or BSD with either Xorg and Wayland. I have no reference of other platforms such as Windows or macOS. ↩︎

Have comments or want to discuss this topic?
Send an email to ~whynothugo/public-inbox@lists.sr.ht (mailing list etiquette)

— § —