sdushantha / farge Goto Github PK
View Code? Open in Web Editor NEWClick on a pixel on your screen and show its color value
License: MIT License
Click on a pixel on your screen and show its color value
License: MIT License
It can be a bit tricky to pinpoint a color that I want. gpick
gives the user a little zoomed in window next to the pointer to make it obvious what you're selecting. Would it be possible to have such a feature in farge? Possibly even use gpick
as an alternative backend?
Hi
I just installed the package from the AUR and when I ran it I received an error informing me that I need to install the dependency xcolor
. This is not mentioned in the readme I thought you might want to add it.
If you're interested I could create a PR for macOS support or you could add if you have access to a mac. I figured it may be better to include this into a single tool.
macOS Reqs:
hammerspoon w/ cli interface installed. Though it might be possible to remove this with a little work.
Proof of Concept:
# NOTE: Heavily inspired by https://apple.stackexchange.com/questions/87801/how-to-get-color-of-pixel-in-coordinates-123-456-in-screen/280851#280851
get_pixel_color () {
# Use hammer spoon to get mouse x,y coords
X=$(hs -A -c "hs.mouse.absolutePosition()['x']")
Y=$(hs -A -c "hs.mouse.absolutePosition()['y']")
# Screenshot pixel at mouse coords save to $TMPDIR
# HEX Dump and grab color
# NOTE: This will require security and privacy permissions to capture the screen
# Testing against known hex colors does not reproduce the same hex, but
# it does produce the color on the screen. Maybe a difference in color profiles
# or colorspace. Maybe someone that knows maybe how to convert srbg to whatever can
# resolve this issue.
COLOR=$(
screencapture -R $X,$Y,1,1 -t bmp $TMPDIR/pixel_color.bmp
xxd -p -l 3 -s 54 $TMPDIR/pixel_color.bmp |
sed 's/\(..\)\(..\)\(..\)/\3\2\1/'
)
# Copy Color to Clipboard
echo "#$COLOR" | pbcopy
# Use applescript to display a native OS notification
# TODO: This could be improved with imagemagick and hammerspoon
osascript -e '
on run argv
display notification "#" & item 1 of argv
end run
' $COLOR
}
The input arguments of colorpicker were changed as of 3 hours ago. Short / s is no longer valid.
I would request you to make this tool also work for Wayland .
Grim is imagepicker can also be used as alternative for Colorpicker .
The command
grim -g "$(slurp -p)" -t ppm - | convert - -format '%[pixel:p{0,0}]' txt:-
picks color in wayland.
It would be glad to see Wayland support as Wayland is future.
Installed farge though AUR on i3wm.
This is the default output without bc (same result with any arg):
➜ ~ farge
/usr/bin/farge: line 104: bc: command not found
/usr/bin/farge: line 104: [: : integer expression expected
With bc the error is not present anymore. Without bc the command is working as expected though so I am not sure what exactly how it is being used.
I'm running KDE on Arch 5.2.1, and I'm getting
(colorpicker:24892): Gdk-CRITICAL **: 06:45:25.595: IA__gdk_screen_get_root_window: assertion 'GDK_IS_SCREEN (screen)' failed
(colorpicker:24892): Gdk-CRITICAL **: 06:45:25.595: IA__gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(colorpicker:24892): Gdk-CRITICAL **: 06:45:25.595: IA__gdk_pointer_grab: assertion 'window != NULL' failed
no matter what.
Colorpicker works fine on my pc, but farge doesn't seem to do anything. When I try to run farge, it outputs
(colorpicker:150836): Gdk-CRITICAL **: 11:19:12.888: IA__gdk_screen_get_root_window: assertion 'GDK_IS_SCREEN (screen)' failed
(colorpicker:150836): Gdk-CRITICAL **: 11:19:12.888: IA__gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(colorpicker:150836): Gdk-CRITICAL **: 11:19:12.888: IA__gdk_pointer_grab: assertion 'window != NULL' failed
to the console, and doesn't exit afterwards. I think gdk has something to do with gnome, which isn't installed on my system but I don't see why farge would depend on gnome. I run x11 with compton and i3 on arch if it helps.
Can I change the font that is used for rendering in the default farge command. I get the following error:
/usr/bin/farge: line 104: bc: command not found
/usr/bin/farge: line 104: [: : integer expression expected
convert: unable to read font `helvetica' @ error/annotate.c/RenderFreetype/1425.
I don't think I have the helvetica font installed and would like to change it.
Thank you!
Hi there,
I am wanting to build and maintain this package for Solus Linux. It would greatly benefit me (and possibly others, if the build system works similarly) if you could make a release with a .tar, since the builder scripts need that. I'd really appreciate it!
Love the tool!
Now if you color pick a black(or dark) color, the hex code is not readable. The script should detect the contrast ratio, and change the text color accordingly.
Following the "usability of farge
" discussion on Reddit, I suggest that, the first time you call farge
, it outputs something like To close the color window, click on it and press 'q'
on the command-line. Since the tool is command-line, this should be a good way to make it more intuitively-usable while still keeping it nice-looking! As for the internals - you could probably just put a flag file in one of the XDG-approved directories (i.e. .config), check for it and no longer show the message once it's been shown once.
Hey there! Love this. First off when installing on Arch Linux I had to grab the dependencies via trial and error:
First got this error about
[saint-llama@hubs ~]$ git clone https://github.com/sdushantha/farge
Cloning into 'farge'...
remote: Enumerating objects: 27, done.
remote: Counting objects: 100% (27/27), done.
remote: Compressing objects: 100% (25/25), done.
remote: Total 27 (delta 9), reused 10 (delta 2), pack-reused 0
Unpacking objects: 100% (27/27), done.
[saint-llama@hubs ~]$ cd farge
[saint-llama@hubs farge]$ sudo make install
[sudo] password for saint-llama:
farge has been installed
[saint-llama@hubs farge]$ farge
/usr/bin/farge: line 45: colorpicker: command not found
No color was selected
So I installed colorpicker via:
[saint-llama@hubs farge]$ cd ..
[saint-llama@hubs ~]$ git clone https://github.com/ym1234/colorpicker.git
Cloning into 'colorpicker'...
remote: Enumerating objects: 20, done.
remote: Counting objects: 100% (20/20), done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 46 (delta 6), reused 15 (delta 3), pack-reused 26
Unpacking objects: 100% (46/46), done.
[saint-llama@hubs ~]$ cd colorpicker
[saint-llama@hubs colorpicker]$ sudo make install
cc -o colorpicker main.c `pkg-config --libs --cflags x11`
mkdir -p /usr/bin/
cp -f colorpicker /usr/bin/
[saint-llama@hubs colorpicker]$ farge
/usr/bin/farge: line 73: xclip: command not found
So I installed xclip via:
[saint-llama@hubs colorpicker]$ sudo pacman -S xclip
resolving dependencies...
looking for conflicting packages...
Packages (1) xclip-0.13-2
Total Download Size: 0.01 MiB
Total Installed Size: 0.06 MiB
:: Proceed with installation? [Y/n] y
:: Retrieving packages...
xclip-0.13-2-x86_64 14.8 KiB 872K/s 00:00 [######################] 100%
(1/1) checking keys in keyring [######################] 100%
(1/1) checking package integrity [######################] 100%
(1/1) loading package files [######################] 100%
(1/1) checking for file conflicts [######################] 100%
(1/1) checking available disk space [######################] 100%
:: Processing package changes...
(1/1) installing xclip [######################] 100%
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...
Now the program runs without error and copies the color hex to clipboard. The only thing is it's not making those tiles with the color preview and hex value. Tried farge
and sudo farge
just for good measure. Not getting any error either so I'm not sure what's up?
I’d love to be able to output color codes via pipe or stdout to record outputs, set environment variables, etc.
Installed through AUR in i3wm. Installed dependencies (using feh) in readme for X11. I am only seeing the color in the preview. I notice in the AUR package colorpicker-ym1234-git
is mentioned as an optional dependency. I was not sure if this is needed to output the color in feh. I tried also with this particular colorpicker package with the same result. I'm not sure whether this is an issue or I just overlooked something.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.