XCOLOR(1) General Commands Manual XCOLOR(1)

xcolor - lightweight color picker for X11

xcolor [-f NAME | -c FORMAT] [-s [SELECTION]] [-S SCALE] [-P PREVIEW_SIZE] [-v] [-h]

xcolor is a lightweight color picker for X11. Use mouse to select colors visible anywhere on the screen to get their RGB representation.

By default, the selected color is printed to the standard output.

Specify output format. Possible values for NAME are hex, HEX, hex!, HEX!, rgb, and plain. See FORMATTING for an explanation of different formatting options. Conflicts with --custom.
Specify template for custom output format. See CUSTOM FORMATTING for an explanation of template syntax. Conflicts with --format.
Save output to X11 selection. Possible values for SELECTION are clipboard, primary and secondary. If SELECTION is not supplied, clipboard is used.
Magnification scale of the picker, defaults to 8
Pixel size of the picker, defaults to 255
Print version information and exit.
Print help message and exit.

By default, the color values are printed in lowercase hexadecimal format. The output format can be changed using the --format NAME switch. The possible NAME values are:

Lowercase hexadecimal (default)
Uppercase hexadecimal
Compact lowercase hexadecimal
Compact uppercase hexadecimal
Decimal RGB
Decimal with semicolon separators

The compact form refers to CSS three-letter color codes as specified by CSS Color Module Level 3. If the color is not expressible in three-letter form, the regular six-letter form will be used.

The --format switch provides quick access to some commonly used formatting options. However, if custom output formatting is desired, this can be achieved using the --custom FORMAT switch. The FORMAT parameter specifies a template for the output and supports a simple template language. FORMAT templates can contain special expansions that are written inside %{...} blocks. These blocks will be expanded into color values according to the specifiers defined inside the block. Here are examples of valid format strings and what they might translate to:

Format String Example Output
%{r}, %{g}, %{b} 255, 0, 100
Green: %{-4g} Green: ---7
#%{02hr}%{02hg}%{02hb} #00ff00
%{016Br} 0000000000000011

Expansion blocks in format strings always contain a channel specifier (r for red, g for green, and b for blue). Additionally, they can contain an optional number format specifier (h for lowercase hexadecimal, H for uppercase hexadecimal, o for octal, B for binary, and d for decimal) and an optional padding specifier consisting of a character to use for padding and the length the string should be padded to. The diagram bellow illustrates how we can use these rules to decode a formatting template:

%{016Br}

| |||
| ||`- Channel (red)
| |`-- Number format specifier (binary)
| `--- Padding length (16)
`----- Character to use for padding (0)

The output is the contents of the red color channel formatted in binary and padded with zeroes to be sixteen characters long.

Disable daemon mode. Because of the way selections work in X11, xcolor forks into background when --selection mode is used. This behavior can be disabled by defining XCOLOR_FOREGROUND environment variable.

Samuel Laurén <samuel.lauren@iki.fi> Callum Osmotherly <acheronfail@gmail.com>

2018