1.2 KiB
+++ title = "Taking screenshots on Wayland with Grim and Slurp" date = 2024-01-18 draft = false
[taxonomies] categories = ["Linux"]
[extra] author = "Emil Miler" +++
I have done some experimenting with dwl and river on Wayland, which requires a change of my X11 setup. This article quickly explains how to replace the old Shotgun and Slop for a simple Wayland alternative.
This replacement is very similar to the original combo. What you need is grim
for screenshots, slurp
for area selection and wl-clipboard
for clipboard features:
grim -g "$(slurp -d)" - | tee /home/$USER/scrot/$(date +'%F_%T').png | wl-copy
The -d
option in slurp
just shows us the selection dimensions, which is a neat feature.
We can also implement a simple color picker, which will grab selected pixel color and copy a hex color output to the clipboard:
grim -g "$(slurp -p)" -t ppm - | convert - -format '%[pixel:p{0,0}]' txt:- | grep -o '#[0-9A-F]\{6\}' | tr -d '\n' | wl-copy
More interesting ways of using Grim can be found at Grim examples.