Skip to content

Instantly share code, notes, and snippets.

@derricw
Created March 1, 2024 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derricw/9dd7aaf0083bd85d3cf64fdf12358e63 to your computer and use it in GitHub Desktop.
Save derricw/9dd7aaf0083bd85d3cf64fdf12358e63 to your computer and use it in GitHub Desktop.
bash color picker
#/bin/bash
color=$(gdbus call --session --dest org.gnome.Shell.Screenshot --object-path /org/gnome/Shell/Screenshot --method org.gnome.Shell.Screenshot.PickColor)
echo "COLOR: $color"
numbers=$(echo $color | sed 's/[^0-9,.]*//g')
echo "FLOAT: $numbers"
rgb=$(echo $numbers | awk -F',' '{ print $1 * 255, $2 * 255, $3 * 255 }')
echo "RGB: $rgb"
printf "HEX: #%x%x%x\n" $rgb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment