Skip to content

Instantly share code, notes, and snippets.

@uncomfyhalomacro
Created March 2, 2022 09:24
Show Gist options
  • Save uncomfyhalomacro/61c1cd5dfcbe24041d386c4465943c60 to your computer and use it in GitHub Desktop.
Save uncomfyhalomacro/61c1cd5dfcbe24041d386c4465943c60 to your computer and use it in GitHub Desktop.
Colorpicker script using wayshot and slurp with ImageMagick
#!/bin/bash
shopt -s lastpipe
COLOR="$(wayshot -s "$(slurp -p -f '%x %y %w %h')" --stdout | magick identify -format '#%[hex:p{0,0}]\n%[pixel:p{0,0}]' -)"
SRGB="$(echo "${COLOR}" | tail -n +2)"
HEX="$(echo "${COLOR}" | head -n +1)"
RESULT="${SRGB} ${HEX}"
[ -z "${COLOR}" ] && exit
notify-send -a "Colorpicker" "Color on selected pixel: ${RESULT}" "Hex value copied to clipboard"
wl-copy "${HEX}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment