Color picker for Wayland

Is there a colour picker that works with Wayland or XWayland? has an answer for Sway:
grim -g "$(slurp -p)" -t ppm - | convert - -format '%[pixel:p{0,0}]' txt:-

After clicking on a target, output like this appears in the terminal:

# ImageMagick pixel enumeration: 1,1,255,srgb
0,0: (64,69,82) #404552 srgb(64,69,82)

Code in this comment extracts the hex value and puts it in Sway’s clipboard:

bindsym $mod+Shift+p exec grim -g "$(slurp -p)" -t ppm - | convert - -format '%[pixel:p{0,0}]' txt:- | tail -n 1 | cut -d ' ' -f 4 | wl-copy

(Instead of tail -n 1 | cut -d ' ' -f 4, one could use awk 'NR==2 { print $3 }')

Shorter code*:

slurp -p | grim -g - - | convert - txt: | tail -n 1 and an optional pipe to | wl-copy

I’ll try it later today.

Edit:

To get just the hex value into the clipboard:
slurp -p | grim -g - - | convert - txt: | awk 'NR==2 { print $3 }' | wl-copy

*the reddit comment from which the code was copied has been “deleted by user” :confused:

I use xcolor. It’s absolutely fantastic and very minimal, but it does not work on Wayland, of course.