Search code examples
macosshellcolors

macOS : Correctly apply a semi-transparent system custom highlight color with shell command


I successfully applied a system custom highlight color with the following shell command: defaults write -g AppleHighlightColor -string "0.400000 0.400000 0.700000 1.000000"

But I noticed that when I apply the custom color via shell command, I get a non-transparent color. Whereas when I apply the custom color via the System Settings menu, I obtain a more suitable semi-transparent color.

I tried to change the opacity of the custom color before applying it with the shell command by decreasing the alpha value, but that doesn't change the result : defaults write -g AppleHighlightColor -string "0.400000 0.400000 0.700000 0.500000"

Something I noticed using defaults read -g AppleHighlightColor after applying the custom color with the command and via System Settings:

  • after I applied the color with the shell command: 0.400000 0.400000 0.700000 1.000000

  • after I applied the same color via System Settings: 0.400000 0.400000 0.700000 Other


Solution

  • As when the color is applied via the menu of System Settings, replace the alpha value of the color (X.XXXXXX) with Other.

    Correct shell command:

    0.400000 0.400000 0.700000 Other