LinuxCommandLibrary

colorpicker

Select colors from the screen

TLDR

Launch colorpicker and print the hexadecimal and RGB value of each clicked pixel to stdout

$ colorpicker
copy

Only print the color of one clicked pixel and then exit
$ colorpicker --one-shot
copy

Print the color of each clicked pixel and quit when a key is pressed
$ colorpicker --quit-on-keypress
copy

Only print the RGB value
$ colorpicker --rgb
copy

Only print the hexadecimal value
$ colorpicker --hex
copy

SYNOPSIS

colorpicker [-h] [-p] [-s] [-x] [-n] [-f FORMAT]

PARAMETERS

-h, --help
    Display help message and exit

-p, --preview
    Show selected color in preview window

-s, --scripted
    Script mode: no pointer grab, requires -f

-x, --xcolor
    Output X11 color string (e.g., #rrggbb)

-n, --noround
    Output exact RGB without rounding

-f FORMAT, --format FORMAT
    Custom output format (default: %{hex}); vars: %{r},%{g},%{b},%{hex},%{name}

DESCRIPTION

Colorpicker is a lightweight command-line utility for Linux/X11 that enables users to select colors directly from the screen. When run, it activates a crosshair cursor; clicking any pixel captures its color and prints details like RGB values or hex codes to stdout.

Perfect for developers scripting themes, designers grabbing palette colors, or sysadmins matching UI elements, it supports flexible output formats via templates (e.g., %{hex}, %r,%g,%b). Options allow previewing the color in a small window, non-interactive scripted mode, X11-compatible strings, and precise RGB without rounding.

Built on Xlib for pixel grabbing, it's fast, dependency-light (just libX11), and integrates seamlessly into pipelines like shell scripts or Vim configs. No GUI overhead—ideal for headless or remote sessions with X forwarding.

CAVEATS

Requires X11 display (fails on pure Wayland); needs pointer grab permission; may conflict with compositors blocking grabs.

EXAMPLES

colorpicker
Picks and prints hex color.

colorpicker -p -f '%r %g %b'
Picks with preview, prints RGB.

xclip -selection clipboard <<< $(colorpicker -f '%{hex}')
Copies hex to clipboard.

FORMAT VARS

%r: red (0-255), %g: green, %b: blue, %{hex}: #RRGGBB, %{name}: X11 name (if exact match).

HISTORY

Originated ~2015 on GitHub (aste123/colorpicker); evolved for minimalism; packaged in Debian, Arch (AUR), Fedora since ~2018.

SEE ALSO

xwd(1), xmag(1), import(1)

Copied to clipboard