Color picker
This commit is contained in:
parent
e51857c4a4
commit
4f5ee21ba2
|
@ -0,0 +1,38 @@
|
|||
#!/bin/sh
|
||||
# Modification of https://github.com/jgmdev/wl-color-picker
|
||||
|
||||
# Check if running under wayland.
|
||||
if [ "$WAYLAND_DISPLAY" = "" ]; then
|
||||
echo "Error: No wayland session found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get color position
|
||||
position=$(slurp -b 00000000 -p)
|
||||
|
||||
# Sleep at least for a second to prevet issues with grim always
|
||||
# returning improper color.
|
||||
#sleep 1
|
||||
|
||||
# Store the hex color value using graphicsmagick or imagemagick.
|
||||
if type gm &> /dev/null; then
|
||||
color=$(grim -g "$position" -t png - \
|
||||
| gm convert - -format '%[pixel:p{0,0}]' txt:- \
|
||||
| tail -n 1 \
|
||||
| rev \
|
||||
| cut -d ' ' -f 1 \
|
||||
| rev
|
||||
)
|
||||
else
|
||||
color=$(grim -g "$position" -t png - \
|
||||
| convert - -format '%[pixel:p{0,0}]' txt:- \
|
||||
| tail -n 1 \
|
||||
| cut -d ' ' -f 4
|
||||
)
|
||||
fi
|
||||
|
||||
# Copy to clipboard
|
||||
echo $color | wl-copy -n
|
||||
|
||||
# Display as a notification
|
||||
notify-send "Copied to clipboard" $color
|
Loading…
Reference in New Issue