zenity/color_unix.go

29 lines
568 B
Go
Raw Normal View History

2022-03-24 10:37:37 -04:00
//go:build !windows && !darwin
2020-01-21 11:13:45 -05:00
package zenity
import (
"image/color"
2024-07-10 00:06:01 -04:00
"git.bigun.dev/evan/zenity/internal/zenutil"
2020-01-21 11:13:45 -05:00
)
2021-03-04 07:42:30 -05:00
func selectColor(opts options) (color.Color, error) {
2020-01-21 11:13:45 -05:00
args := []string{"--color-selection"}
2022-06-02 07:24:24 -04:00
args = appendGeneral(args, opts)
2020-01-21 11:13:45 -05:00
if opts.color != nil {
args = append(args, "--color", zenutil.UnparseColor(opts.color))
}
2020-01-24 07:52:45 -05:00
if opts.showPalette {
2020-01-21 11:13:45 -05:00
args = append(args, "--show-palette")
}
2020-01-28 07:46:43 -05:00
out, err := zenutil.Run(opts.ctx, args)
2021-04-29 11:05:28 -04:00
str, err := strResult(opts, out, err)
if err != nil {
return nil, err
2020-01-21 11:13:45 -05:00
}
2021-04-29 11:05:28 -04:00
return zenutil.ParseColor(str), nil
2020-01-21 11:13:45 -05:00
}