update colorpicker to use kdialog

This commit is contained in:
Penelope Gwen 2026-06-30 12:11:35 -07:00 committed by Penelope Gwen
parent c256e098ec
commit 146a79063a

View file

@ -28,14 +28,14 @@ NO_NOTIFY=0
while [ "$1" ]; do
case $1 in
'-h' | '--help' | 'help' | '?' )
'-h' | '--help' | 'help' | '?')
showhelp
exit
;;
'clipboard' )
'clipboard')
CLIPBOARD=1
;;
'--no-notify' )
'--no-notify')
NO_NOTIFY=1
;;
esac
@ -45,9 +45,8 @@ done
# Check if running under wayland.
if [ "$WAYLAND_DISPLAY" = "" ]; then
zenity --error --width 400 \
--title "No wayland session found." \
--text "This color picker must be run under a valid wayland session."
kdialog --error "This color picker must be run under a valid wayland session." \
--title "No wayland session found."
exit 1
fi
@ -60,19 +59,21 @@ position=$(slurp -b 00000000 -p)
sleep 1
# Store the hex color value using graphicsmagick or imagemagick.
if command -v /usr/bin/gm &> /dev/null; then
color=$(grim -g "$position" -t png - \
| /usr/bin/gm convert - -format '%[pixel:p{0,0}]' txt:- \
| tail -n 1 \
| rev \
| cut -d ' ' -f 1 \
| rev
if command -v /usr/bin/gm &>/dev/null; then
color=$(
grim -g "$position" -t png - |
/usr/bin/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
color=$(
grim -g "$position" -t png - |
convert - -format '%[pixel:p{0,0}]' txt:- |
tail -n 1 |
cut -d ' ' -f 4
)
fi
@ -83,9 +84,10 @@ if [ $CLIPBOARD -eq 1 ]; then
fi
else
# Display a color picker and store the returned rgb color
rgb_color=$(zenity --color-selection \
rgb_color=$(
kdialog --getcolor \
--title="Copy color to Clipboard" \
--color="${color}"
--default "${color}"
)
# Execute if user didn't click cancel