Minimal X11 Color Picker and Magnifier
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
NRK 6bdf3cd4c4 release v0.7.2 6 days ago
.clang-tidy switch to clang-tidy's yaml config 1 week ago
LICENSE GPLv3, very important 1 year ago README: suggest `install` as alternative 1 week ago init 1 week ago
config.h rm config.def.h 1 week ago
sxcs.1 release v0.7.2 6 days ago
sxcs.c release v0.7.2 6 days ago

sxcs - Simple X Color Sniper


Color picker and magnifier for X11.



Button1 will select and print the color to stdout, the output is TAB separated hex, rgb, and hsl. Scroll Up/Down will zoom in and out. Any other mouse button will quit sxcs.

Output format can be chosen via cli argument. Zoom/magnification can be disabled via --mag-none.

$ sxcs --rgb --mag-none
rgb:	22 158 111

Copying the hex output to clipboard (using xclip):

$ sxcs -o --hex | cut -f 2 | xclip -in -selection clipboard

Color output can be disabled via --color-none, which more or less turns sxcs into a magnifier.

The magnifying window can be customized via using --mag-filters <filter-list>, where filter-list is a comma separated list of filters to apply. The filter-list will be applied in order, as given by the user.

The default filter list is the following:

$ sxcs --mag-filters "grid,circle,xhair"

Following are a couple more examples:

$ sxcs --mag-filters "square,xhair"
$ sxcs --mag-filters "grid,xhair"

Consult the manpage to see a list of all available cli arguments and filters:

$ man sxcs


  • Build Dependencies:

    • C89 compiler
    • necessary headers
  • Runtime Dependencies:

    • Xlib
    • Xcursor
    • POSIX 2001 C standard library


  • Simple build:
$ cc -o sxcs sxcs.c -s -l X11 -l Xcursor
  • Recommended optimized build:
$ gcc -o sxcs sxcs.c -Ofast -march=native -fwhole-program -fno-plt \
    -fno-semantic-interposition -fgraphite-identity -floop-nest-optimize \
    -fipa-pta -fno-asynchronous-unwind-tables -fno-ident -fno-pie \
    -s -no-pie -l X11 -l Xcursor
  • Recommended debug build:
$ gcc -o sxcs sxcs.c -std=c89 -Wall -Wextra -Wpedantic \
    -g3 -D DEBUG -O0 -fsanitize=address,undefined -l X11 -l Xcursor
  • Optionally run some static analysis:
$ make -f


Just copy the executable and the man-page to the appropriate location:

$ sudo cp sxcs /usr/local/bin
$ sudo cp sxcs.1 /usr/local/share/man/man1

Or using the install utility:

$ sudo install -Dm755 sxcs /usr/local/bin/sxcs
$ sudo install -Dm644 sxcs.1 /usr/local/share/man/man1/sxcs.1


Cursor size bigger than 255x255 causes visual glitches, it seems to be a X11/Xcursor limitation.

One alternative would be using XComposite and using an override_redirect window. Which is what was being done (incorrectly) before commit 33490dd. I suspect doing this correctly would require way too much code, probably above my self imposed limit of ~800 SLoC for this project.


grep the source to find TODOs:

$ grep -Hn -E 'TODO|FIXME' sxcs.c