-
Notifications
You must be signed in to change notification settings - Fork 174
feat(color-picker): add color-picker extension #404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
manuelcontrera
wants to merge
3
commits into
vicinaehq:main
Choose a base branch
from
manuelcontrera:feat/add-color-picker
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| node_modules | ||
| vicinae-env.d.ts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # Color Picker for Vicinae | ||
|
|
||
| A powerful color picker, manager, and converter extension for **Vicinae** on **Linux**, ported and adapted from Raycast's Color Picker. | ||
|
|
||
| Supported on **Linux** (GNOME, KDE, Hyprland, Sway, Wayland, and X11). | ||
|
|
||
| --- | ||
|
|
||
| ## Commands | ||
|
|
||
| ### `pick-color` - Pick Color | ||
| Activates a screen loupe/eyedropper across your monitors, allowing you to sample any pixel. | ||
| - Copies the sampled color directly to the clipboard in your preferred format. | ||
| - Adds the color to your persistent color history. | ||
| - Shows a HUD confirmation with the copied color. | ||
|
|
||
| ### `organize-colors` - Organize Colors | ||
| Manage, search, and export your picked color history. | ||
| - View in grid mode (with live SVG color swatches) or list mode. | ||
| - Pin your favorite colors to the top. | ||
| - Rename colors with custom titles. | ||
| - Copy colors in 12 different formats (HEX, RGB, RGBA, HSL, HSV, OKLCH, LCH, Display P3, etc.). | ||
| - Export colors as CSS variables, CSS classes, or JSON. | ||
| - Trigger color sampling directly with a single click. | ||
|
|
||
| ### `favorite-colors` - Favorite Colors | ||
| Quick access to all colors pinned as favorites in Organize Colors. | ||
|
|
||
| ### `convert-color` - Convert Color | ||
| Universal color conversion tool. Pass any color format (or enter one in the search bar) to immediately get conversions in all major formats with one-click copy. | ||
|
|
||
| ### `color-names` - Color Names | ||
| Search and identify colors by their descriptive names using the `color-namer` palette. | ||
|
|
||
| ### `color-wheel` - Color Wheel Reference | ||
| Displays an RGB spectrum color wheel reference with quick access to the desktop screen picker. | ||
|
|
||
| --- | ||
|
|
||
| ## Screen Picker Architecture | ||
|
|
||
| - **Linux**: Uses D-Bus color picking through `org.freedesktop.portal.Screenshot.PickColor` and `org.gnome.Shell.Screenshot.PickColor`. | ||
|
|
||
| --- | ||
|
|
||
| ## Preferences | ||
|
|
||
| - **Color Format**: Default format when copying picked colors (`HEX`, `HEX Lower Case`, `HEX No Prefix`, `RGB`, `RGB %`, `RGBA`, `RGBA %`, `HSLA`, `HSVA`, `OKLCH`, `LCH`, `P3`). | ||
| - **Show color name after picking**: Optionally show the matched color name in the notification after sampling. | ||
| - **Primary Action**: Configure whether selecting a color copies it to the clipboard or pastes it directly to the frontmost application. | ||
|
|
||
| --- | ||
|
|
||
| ## Credits | ||
|
|
||
| - Ported and maintained for Vicinae by [manuelcontrera](https://github.com/manuelcontrera). | ||
| - Original Raycast extension created by [thomas](https://github.com/thomas). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| #!/usr/bin/env python3 | ||
| import sys | ||
| import json | ||
| import uuid | ||
|
|
||
| def try_gnome(bus): | ||
| try: | ||
| from gi.repository import Gio | ||
| proxy = Gio.DBusProxy.new_sync( | ||
| bus, | ||
| Gio.DBusProxyFlags.NONE, | ||
| None, | ||
| 'org.gnome.Shell.Screenshot', | ||
| '/org/gnome/Shell/Screenshot', | ||
| 'org.gnome.Shell.Screenshot', | ||
| None | ||
| ) | ||
| res = proxy.call_sync('PickColor', None, Gio.DBusCallFlags.NONE, 60000, None) | ||
| val = res.unpack()[0] | ||
| if 'color' in val: | ||
| r, g, b = val['color'] | ||
| return { | ||
| "red": float(r), | ||
| "green": float(g), | ||
| "blue": float(b), | ||
| "alpha": 1.0, | ||
| "colorSpace": "sRGB" | ||
| } | ||
| return None | ||
| except Exception as e: | ||
| err_msg = str(e).lower() | ||
| if "cancel" in err_msg or "abort" in err_msg or "dismiss" in err_msg: | ||
| return "CANCELLED" | ||
| return None | ||
|
|
||
| def try_portal(bus): | ||
| try: | ||
| from gi.repository import Gio, GLib | ||
| loop = GLib.MainLoop() | ||
| token = "picker_" + uuid.uuid4().hex[:8] | ||
| sender = bus.get_unique_name()[1:].replace('.', '_') | ||
| handle_path = f"/org/freedesktop/portal/desktop/request/{sender}/{token}" | ||
|
|
||
| result_color = None | ||
|
|
||
| def on_signal(connection, sender_name, object_path, interface_name, signal_name, parameters, user_data): | ||
| nonlocal result_color | ||
| try: | ||
| response_code, results = parameters.unpack() | ||
| if response_code == 0 and 'color' in results: | ||
| r, g, b = results['color'] | ||
| result_color = { | ||
| "red": float(r), | ||
| "green": float(g), | ||
| "blue": float(b), | ||
| "alpha": 1.0, | ||
| "colorSpace": "sRGB" | ||
| } | ||
| finally: | ||
| loop.quit() | ||
|
|
||
| bus.signal_subscribe( | ||
| None, | ||
| "org.freedesktop.portal.Request", | ||
| "Response", | ||
| handle_path, | ||
| None, | ||
| Gio.DBusSignalFlags.NONE, | ||
| on_signal, | ||
| None | ||
| ) | ||
|
|
||
| params = GLib.Variant.new_tuple( | ||
| GLib.Variant.new_string(""), | ||
| GLib.Variant('a{sv}', {'handle_token': GLib.Variant('s', token)}) | ||
| ) | ||
|
|
||
| bus.call_sync( | ||
| "org.freedesktop.portal.Desktop", | ||
| "/org/freedesktop/portal/desktop", | ||
| "org.freedesktop.portal.Screenshot", | ||
| "PickColor", | ||
| params, | ||
| None, | ||
| Gio.DBusCallFlags.NONE, | ||
| -1, | ||
| None | ||
| ) | ||
| loop.run() | ||
| return result_color | ||
| except Exception: | ||
| return None | ||
|
|
||
| def main(): | ||
| try: | ||
| from gi.repository import Gio | ||
| bus = Gio.bus_get_sync(Gio.BusType.SESSION, None) | ||
| except Exception as e: | ||
| sys.stderr.write(f"Failed to connect to D-Bus: {e}\n") | ||
| sys.exit(2) | ||
|
|
||
| # 1. First try GNOME Shell native loupe (direct, no portal prompt) | ||
| color = try_gnome(bus) | ||
| if color == "CANCELLED": | ||
| sys.exit(1) | ||
| if color: | ||
| print(json.dumps(color)) | ||
| sys.exit(0) | ||
|
|
||
| # 2. Fallback to XDG Desktop Portal (KDE, Wayland compositors) | ||
| color = try_portal(bus) | ||
| if color: | ||
| print(json.dumps(color)) | ||
| sys.exit(0) | ||
|
|
||
| sys.exit(1) | ||
|
|
||
| if __name__ == "__main__": | ||
| main() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 Warning — Documented native picker fallbacks are not implemented
Rule:
MANIFEST-001The README claims fallbacks through
hyprpicker,grim/slurp,xcolor,gpick, andimport, but the supplied picker only attempts GNOME Shell and XDG Desktop Portal D-Bus APIs and never invokes those tools.Suggested resolution: Remove the fallback-tool claim or implement the documented fallback paths.