blob: 85611295d3a82944cd6585aeea7389ea6cfc3a3f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#!/bin/sh
set -e
[ -n "$DEBUG" ] && set -x
# check requirements
for tool in convert grim slurp wl-copy; do
if ! command -v "$tool" >/dev/null; then
printf "%s: %s not installed but required\n" "$(basename "$0")" "$tool" >&2
exit 1
fi
done
# src: https://git.sr.ht/~sircmpwn/dotfiles/tree/f9e7e88a72c2b87e5ab823205cb3a3aa8f3babd0/bin/colorpick
notify-send "pick a color"
color=$(grim -g "$(slurp -p -b 00000000)" - | convert - txt:- | awk 'END{print $3}')
icn=$(mktemp).png
trap '{ rm $icn; }' EXIT
convert -size '30x30' xc:white -fill "$color" -draw "rectangle 0,0 30,30" "$icn"
wl-copy "$color"
notify-send -i "$icn" "color copied to clipboard" "$color"
|