hyprpicker

repository·main·Indexed 22 days ago

https://github.com/hyprwm/hyprpicker

A Wayland color picker compatible with wlroots that allows users to select colors from their screen. It supports multiple output formats (CMYK, HEX, RGB, HSL, HSV), custom output templates, and automatic copying to the clipboard via wl-copy. Features include a magnifying lens for selection, configurable zoom scale and circle radius, and optional desktop notifications.

Tokens
2K
Snippets
12
Records
16
Agent score
76%

What's inside hyprpicker

  1. Build hyprpicker from source

    main

    To build hyprpicker manually, you must first install the following dependencies:

    • cmake
    • pkg-config
    • pango
    • cairo
    • wayland
    • wayland-protocols
    • hyprutils
    • xkbcommon

    Follow these steps to build and install the binary:

    # Configure the build directory
    cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build
    
    # Build the project using all available CPU cores
    cmake --build ./build --config Release --target hyprpicker -j`nproc 2>/dev/null || getconf _NPROCESSORS_CONF`
    
    # Install the binary
    cmake --install ./build
  2. Use hyprpicker to pick colors

    main

    To use hyprpicker, run the command in your terminal. Upon invocation, your cursor will transform into a magnifying lens. Click on any pixel on your screen to select its color. The selected color will be printed to standard output (stdout).

    $ hyprpicker
  3. Configure output formatting with --format and --output-format

    main

    Hyprpicker allows you to define both the color space and the string template used for output.

    1. Set the color space using --format (or -f). Supported values: cmyk, hex, rgb, hsl, hsv.
    2. Set the template using --output-format (or -o). This uses a format string where {0}, {1}, {2}, and {3} correspond to the color components.

    Default templates based on format:

    • cmyk: {0}% {1}% {2}% {3}%
    • hex: #{0}{1}{2}
    • rgb: {0} {1} {2}
    • hsl: {0} {1}% {2}%
    • hsv: {0} {1}% {2}%
    # Example: Custom RGB output format
    hyprpicker -f rgb -o "rgb({0}, {1}, {2})"
  4. Examples of hyprpicker usage

    main

    Common usage patterns for hyprpicker:

    Basic color pick:

    $ hyprpicker

    Get a pixel's color in HSL, wrapped in a CSS function: This example uses sed to transform the raw HSL output into a valid CSS hsl() string.

    $ hyprpicker -f hsl | sed 's/^/hsl(/; s/$/)/; y/ /,/'
  5. Configure hyprpicker visual settings

    main

    The following members control the visual appearance and scaling of the color picker interface:

    • m_fZoomScale: A float determining the magnification level (default is 10.0).
    • m_iCircleRadius: An integer defining the radius of the selection circle (default is 100).
    • m_bFancyOutput: A boolean to enable/disable fancy output rendering.
  6. Configure hyprpicker behavior flags

    main

    The CHyprpicker class manages several boolean configuration flags that control the application's behavior. These flags determine how the picker interacts with the system and how it renders:

    • m_bAutoCopy: Automatically copy the selected color to the clipboard.
    • m_bNotify: Send a notification when a color is picked.
    • m_bRenderInactive: Render the picker surface even when it is not the focused window.
    • m_bNoZoom: Disable the zoom effect.
    • m_bNoFractional: Disable fractional scaling support.
    • m_bDisablePreview: Disable the color preview.
    • m_bUseLowerCase: Use lowercase for hex color codes.
    • m_bIncludeCursor: Include the cursor position in the color selection.
    • m_bCopyStandardColorName: Attempt to copy the standard color name along with the color value.
  7. Available color output modes

    main

    When configuring hyprpicker, you can specify the format of the color output using the eOutputMode enumeration. The supported modes are:

    • OUTPUT_CMYK (0)
    • OUTPUT_HEX (1)
    • OUTPUT_RGB (2)
    • OUTPUT_HSL (3)
    • OUTPUT_HSV (4)
    enum eOutputMode : uint8_t {
        OUTPUT_CMYK = 0,
        OUTPUT_HEX,
        OUTPUT_RGB,
        OUTPUT_HSL,
        OUTPUT_HSV,
    };
  8. Reference: hyprpicker CLI flags

    main

    The following flags are available for the hyprpicker command:

    ShortLongDescription
    -a--autocopyAutomatically copies the output to the clipboard (requires wl-clipboard)
    -f--format=fmtSpecifies the output format (cmyk, hex, rgb, hsl, hsv)
    -o--output-format=fmtSpecifies how the output color should be formatted (e.g. rgb({0}, {1}, {2}))
    -n--notifySends a desktop notification (requires notify-send)
    -b--no-fancyDisables the "fancy" (colored) outputting
    -h--helpShow this help message
    -r--render-inactiveRender (freeze) inactive displays
    -z--no-zoomDisable the zoom lens
    -q--quietDisable most logs (leaves errors)
    -v--verboseEnable more logs
    -t--no-fractionalDisable fractional scaling support
    -d--disable-previewDisable live preview of color
    -c--cursorInclude cursor in the frozen preview
    -l--lowercase-hexOutputs the hexcode in lowercase
    -s--scale=scaleSet the zoom scale (between 1 and 10)
    -u--radius=radiusSet the circle radius (between 1 and 1000)
    -N--nameCopies the standard color name instead of the format if matched (requires -a)
    -V--versionPrint version info