I don’t really understand your workflow. Could it be possible you describe it more clearly ? If Hex color you can use the above script to transform to RGB color then use a component to transform it to CMYK.
I have done one in Nautilus for that