Screenshot plus post-modification in Wayland environment

The screenshot function is used in many scenarios in daily work. When you want to explain a certain problem to your partner, a picture is worth a thousand words. The so-called picture has the truth. After the screenshot is completed, it is usually necessary to modify the annotations, such as red boxes in key places, operation steps, arrow guidance and so on.

There are a lot of screenshot software in the Linux environment, but there are only a handful of them that are actually useful, and there are many bugs in the related software in the wayland environment. I used to think that flameshot was good, but I encountered many problems in the dual-screen environment. When I often upgraded to a certain version, I couldn’t select dual-screen screenshots at the same time, and it was difficult to enter text. After switching to the labwc environment, even the frame range is extremely delayed. After struggling for a while, I chose the combination of grim + slurp + swappy, as shown below, just bind a shortcut key.

1grim -g "`slurp`" - | swappy -f -

grim screenshot, slurp selection range, swappy post-modification.

This combination is basically enough, but it was quickly discovered that swappy’s late-stage capabilities are insufficient, such as the inability to add step instructions (that is, the function of displaying steps 1, 2, 3, etc. on the picture). This function is very convenient and quick when describing a certain operation step. It is needed when writing various tutorials on this site, and it is also needed when working in demonstration operations.

Seeing that someone raised an issue, I also added a reply and hoped that the author would add this feature.


In modern society, everyone is very busy. Authors who have completed core functions and made them open source should be rewarded. Users cannot request them unlimitedly. Of course, suggestions for reference are encouraged. This function has to be added by capable people (maybe I will become this kind of person one day in the future, but it is not enough at this stage, maybe after retirement).

It is in this case that a post-software replacement for swappy ksnip was found. The project is relatively active, with more than 100 contributors, and the trial function is normal in the wayland environment.

The installation is very simple, just check the project description page, so I won’t go into details here.

The difficulty lies in how to combine it with grim slurp and bind a system shortcut key to trigger it.

Combined use

  • wrong practice

    At the beginning, I used it like this, I can only take a screenshot once, and the second time it prompts that the picture cannot be found.

    1grim -g "`slurp`" - | ksnip -

    Haven't found the reason yet, sorry.

  • the right way

    1➜ cat
    4NOW=$(date +"%Y-%m-%d-%H%M%S")
    5grim -g "$(slurp )" -t png $HOME/Pictures/grim-$NOW.png
    6ksnip $HOME/Pictures/grim-$NOW.png

    The principle is simple. First save the screenshot in the Pictures directory, and then use ksnip for post-processing. Each performs its duties and the logic is clear. Put the script in a certain directory, and then bind the shortcut key:

    1  <keybind key="Print">
    2    <action>
    3      <name>Execute</name>
    4      <!-- <command>sh -c 'grim -g "`slurp`" - | swappy -f -'</command> -->
    5      <command>$HOME/.config/labwc/</command>
    6    </action>
    7  </keybind>

    Each desktop environment has a different way of setting shortcut keys. Here I am configuring the shortcut in rc.xml in labwc as shown above. Press the Print key, which is the screenshot shortcut key on the keyboard, to trigger the execution of the $HOME/.config/labwc/ script. The process is smooth and simple. The pictures in this article are generated using this combination of operations.

Careful readers may ask, how to complete full screen/active window/single screen? Refer to grim documentation. You can also try whether ksnip can be completed independently (documentation is supported in some environments in the form), most of the time I only need to select a range of screenshots, so the impact is not big .

In addition, ksnip has other interesting functions, such as adding watermarks (watermark), emoticons, etc.


As shown in the figure above:

  • Icon 1, Blur function, blocks sensitive information;
  • Icon 2, custom stickers (configured in options/Settings/Annotator/Stikers, will appear in the emoticon list), interesting features;
  • Icon 3, several built-in emoticons;
  • Icon 4, watermark (configured in options/Settings/Annotator/Watermark).

Finally, open source software can continue to evolve, depending on what kind of community environment it is in. With more than 100 contributors, ksnip has reason to believe that it can continue to improve. Readers can explore more functions by themselves, thank you for reading this article.

Lastmod: Monday, August 28, 2023

See Also: