dotfiles/.local/bin/xcolor-pick
2024-04-23 07:46:41 +05:00

24 lines
636 B
Bash
Executable File

#!/usr/bin/env bash
# Simple Script To Pick Color Quickly Using Gpick.
CMD=$(gpick --no-newline -pso)
TMP=/tmp/xcolor_$CMD.png
check_dependencies() {
! command -v gpick &>/dev/null &&
notify-send -u critical -a "Color Picker" xcolor-pick "gpick needs to be installed" && exit 1
! command -v magick &>/dev/null &&
notify-send -u critical -a "Color Picker" xcolor-pick "imagemagick needs to be installed" && exit 1
}
main() {
convert -size 120x120 xc:"$CMD" "$TMP"
printf %s "$CMD" | xclip -selection clipboard
notify-send -a "Color Picker" -i "$TMP" xcolor-pick "$CMD"
}
check_dependencies
main