PHP Classes

How to Use a PHP Color Picker That Can Pick Colors from User Screens with the Package Ypsilon Picker PHP CLI: Pick a color of any point on a screen

Recommend this page to a friend!
     
  Info   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-03-03 (5 days ago) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
ypsilonpicker-php 1MIT/X Consortium ...7.4PHP 5, Graphics, Tools, GUI, Console
Description 

Author

This package can pick a color of any point on a screen.

It provides a script that calls a class to use the gdbus command from a Linux distribution that uses Wayland based Gnome environment to let the user pick a point on the screen.

The class can get the color value of the point picked by the user to display on the terminal console and copy to the clipboard

This package is for GNOME users only, since the new Wayland protocol has made X11 based "Color pickers" useless, and X11 based were practically all of them.

Picture of Engin Ypsilon
  Performance   Level  
Name: Engin Ypsilon <contact>
Classes: 7 packages by
Country: Germany Germany
Innovation award
Innovation award
Nominee: 3x

Winner: 1x

Details

Ypsilon Picker (PHP CLI) ?

Authors: ChatGPT by OpenAI & Engin Ypsilon by class:Parent()

Overview

Ypsilon Picker is a simple terminal-based color picker for Wayland-based GNOME desktops. Click anywhere on the screen and instantly retrieve the RGB and HEX values of the selected color.

Features

  • ? Wayland-compatible ? Works on modern GNOME, unlike X11-based pickers.
  • ? Minimal & fast ? A single PHP script with no dependencies beyond PHP and GNOME?s built-in tools.
  • ? Optional clipboard support ? Automatically copies the HEX value to your clipboard.
  • ? Easy access ? Use it as a CLI tool or create a desktop launcher for quick access.

Installation

Ypsilon Picker is a lightweight PHP script (~50 lines of code) that requires no dependencies beyond GNOME. You can run it directly or set up a shortcut for convenience.

1. Install the script

Clone this repository into your local <ins>bin</ins> directory (or another preferred location):

mkdir -p ~/bin/ypsilonpicker-php
cd ~/bin/ypsilonpicker-php
git clone https://github.com/eypsilon/ypsilonpicker-php.git .
chmod +x YpsilonPicker.php

Usage

Simply run:

~/bin/ypsilonpicker-php/YpsilonPicker.php

__Example output after selection__

Click anywhere on the screen to pick a color...
RGB: 23 20 33
HEX: #171421
HEX copied to clipboard!

\* If wl-clipboard is installed, the HEX value is automatically copied to your clipboard:

sudo apt install wl-clipboard

Optional Setup

*1. Create a Bash Alias (for CLI users)*

To shorten the command, add this alias to your <ins>.bashrc</ins> or <ins>.zshrc</ins>:

# sudo nano ~/.bash_aliases
alias ypick="~/bin/ypsilonpicker-php/YpsilonPicker.php"

# Reload your shell
source ~/.bashrc
# or source ~/.zshrc

Now, simply type ypick in the terminal to launch it! ??

*2. Create a Desktop Launcher (for GUI users)*

If you want to launch Ypsilon Picker from your application menu, create a <ins>.desktop</ins> file.

  • Create the launcher file:
# Do NOT use `sudo` to avoid permission issues
nano ~/.local/share/applications/ypsilonpicker.desktop

  • Add the following content:
[Desktop Entry]
Name=Ypsilon Picker
Comment=Pick colors from the screen
Exec=gnome-terminal --geometry=60x12+100+100 -- bash -c "php ~/bin/ypsilonpicker-php/YpsilonPicker.php; exec bash"
Icon=preferences-color
Terminal=true
Type=Application
Categories=Utility;

  • Save and close the file (Ctrl+o, then Enter, then Ctrl-x).

Now, you can search for "Ypsilon Picker" in your application menu and run it like a boss! ?

Troubleshooting (if the launcher doesn?t work)

Ensure correct ownership (only needed if you used sudo when creating the file):

sudo chown $USER:$USER ~/.local/share/applications/ypsilonpicker.desktop

Mark the file as trusted (to avoid untrusted application warnings):

gio set ~/.local/share/applications/ypsilonpicker.desktop metadata::trusted true

Update the desktop database (if the launcher doesn?t appear):

update-desktop-database ~/.local/share/applications/

Alternative: Bash Version

If you prefer a Bash script instead of PHP, use this:

#!/bin/bash
# Ypsilon Picker (Bash)
echo "Click anywhere on the screen to pick a color..."
sleep 0.5

output=$(gdbus call --session --dest org.gnome.Shell.Screenshot --object-path /org/gnome/Shell/Screenshot --method org.gnome.Shell.Screenshot.PickColor)
colors=($(echo $output | grep -o "[0-9\.]*"))

LC_NUMERIC=C
for ((i = 0; i < ${#colors[@]}; i++)); do
    colors[$i]=$(echo "${colors[$i]} * 255" | bc | awk '{printf "%.0f\n", $1}')
done

echo "RGB: ${colors[0]} ${colors[1]} ${colors[2]}"
printf "HEX: #%02x%02x%02x\n" "${colors[0]}" "${colors[1]}" "${colors[2]}"

Just save it as ypsilonpicker.sh, make it executable, and run it:

chmod +x ypsilonpicker.sh
./ypsilonpicker.sh

> 2. Alternative: GNOME Shell extension version

License

MIT License

<!-- Tags for searchability --> Tags: Color-Picker Wayland-Color-Picker Linux-Color-Picker GNOME-Color-Picker CLI-Color-Picker RGB-Hex-Extractor PHP-Terminal-Tool Open-Source-Color-Picker


  Files folder image Files (3)  
File Role Description
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file readme.md Doc. Documentation
Plain text file YpsilonPicker.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads  
 100%
Total:0
This week:0