aboutsummaryrefslogtreecommitdiff
path: root/hypr/.config/hypr/scripts/colorpicker
blob: 8f214eb0d65f44becbf3c9287b5a6bbff0635b8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash

## Simple Script To Pick Color Quickly.

color=$(grim -g "$(slurp -b 1B1F2800 -p)" -t ppm - | convert - -format '%[pixel:p{0,0}]' txt:- | tail -n1 | cut -d' ' -f4)
image=/tmp/${color}.png

main() {
	if [[ "$color" ]]; then
		# copy color code to clipboard
		echo $color | tr -d "\n" | wl-copy
		# generate preview
		convert -size 48x48 xc:"$color" ${image}
		# notify about it
		notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i ${image} "$color, copied to clipboard."
	fi
}

# Run the script
main