soft / xcolor Goto Github PK
View Code? Open in Web Editor NEWLightweight color picker for X11
Home Page: https://soft.github.io/xcolor/
License: MIT License
Lightweight color picker for X11
Home Page: https://soft.github.io/xcolor/
License: MIT License
Currently, the save to selection functionality does not support very large data transfers. This is likely not too critical for xcolor's use case as color representations tend to be small but could in theory be a problem when using a custom template.
I'm using Xfce4/xfwm4 on Arch.
When I use xlock the display "freezes", however the mouse pointer itself is moveable. "Freezing" in this case means: Nothing is clickable and not even xeyes follows the mouse pointer.
After switching to a tty and right back to my X session, everything is working again like it should and I xcolor prints the hex code of the selected pixel to stdout.
What I also noticed: When I'm zoomed in (alt+mousewheel) and then use xcolor, it doesn't freeze. However, the circular zoomed-in preview of xcolor is not really displaying what is around the cursor in that case.
Edit: The preview seems to be the problem
xcolor -P 127
(and lower number) works without problem
xcolor -P 128
(and higher numbers; the default without -P has a higher number) let the problem appear
It would be really cool to better test xcolor in the CI. Currently, we only have unit tests for the parsing code but do not test X11 related code.
We could use Xorg with dummy output to test various features, check that colors can be selected and they are the correct colors and so on.
If I left-click while moving the mouse (especially when moving fast), sometimes xcolor does not catch the left-click, and instead keep running as if there were no clicks.
My preliminary debugging shows that, in wait_for_location
function, there are indeed no left-click event received when this happens. Maybe the event is somehow lost when there are too many events (the mouse moving) to handle.
It would be usefull to have some prebuild deb files at https://github.com/Soft/xcolor/releases
Hi,
I see my cpu constantly staying at ~50% and spiking to ~60% on occasion when moving the cursor around with xcolor
. Don't believe such high cpu usage should be necessary for whats being done.
Hello and thank you all for this amazing tool.
I was wondering if there's an interest in adding different color function outputs (particularly for HSL, for now). I was thinking of making a PR, but I wasn't certain if that fits within the vision of its maintainers.
In terms of implementation, I was thinking of performing a conversion from RGB, right before printing the output. However, and I'm not familiar with the problems in color conversions, conversions may be lossy (e.g. RGB to HSL). To make things worse, HSL, for example, uses decimals, i.e floating point math, which is
What do you all think? Is it worth pursuing?
i installed xcolor on debian with:
cargo install xcolor
But after that i got no starter in my menu.
Is there a better solution to install it?
I found the starter in the source code, but it was not installed.
https://github.com/Soft/xcolor/blob/master/extra/xcolor.desktop
Just a minor request; would it be possible to add a right click to cancel xcolor? Often times I find myself using xcolor just for the (pixel perfect) zoom.
I've installed the 2 dependencies:
Building and running xcolor requires xcb and Xlib libraries to be present.
$ sudo apt-get install libx11-dev libx11-xcb-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libx11-dev is already the newest version (2:1.6.9-2ubuntu1.2).
libx11-xcb-dev is already the newest version (2:1.6.9-2ubuntu1.2).
0 upgraded, 0 newly installed, 0 to remove and 65 not upgraded.
And this is the error I get when I try to install xcolor:
$ cargo install xcolor Updating crates.io index
Installing xcolor v0.5.1
Compiling libc v0.2.103
Compiling bitflags v1.2.1
Compiling autocfg v1.0.1
Compiling pkg-config v0.3.20
Compiling unicode-width v0.1.9
Compiling memchr v2.4.1
Compiling strsim v0.8.0
Compiling vec_map v0.8.2
Compiling ansi_term v0.11.0
Compiling cfg-if v1.0.0
Compiling log v0.4.14
Compiling version_check v0.9.3
Compiling anyhow v1.0.44
Compiling minimal-lexical v0.1.4
Compiling lazy_static v1.4.0
Compiling memoffset v0.6.4
Compiling textwrap v0.11.0
Compiling x11 v2.19.1
Compiling nom v7.0.0
error: failed to run custom build command for `x11 v2.19.1`
Caused by:
process didn't exit successfully: `/tmp/cargo-installMZTK9K/release/build/x11-fe4f423cee939653/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-env-changed=X11_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=X11_STATIC
cargo:rerun-if-env-changed=X11_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Command { command: "\"pkg-config\" \"--libs\" \"--cflags\" \"x11\" \"x11 >= 1.4.99.1\"", cause: Os { code: 2, kind: NotFound, message: "No such file or directory" } }', /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/x11-2.19.1/build.rs:40:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to compile `xcolor v0.5.1`, intermediate artifacts can be found at `/tmp/cargo-installMZTK9K`
Caused by:
build failed
Any ideas?
Hello!
I update the PKGBULD locally to get the latest release on aur and also fix the comments that mention the missing license file in /usr/share/licenses/%{pkgname}. If you want to apply the patch here it is:
diff --git a/.SRCINFO b/.SRCINFO
index 1d10a8c..fbe43c7 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,6 +1,6 @@
pkgbase = xcolor
pkgdesc = Lightweight color picker for X11
- pkgver = 0.4.0
+ pkgver = 0.5.0
pkgrel = 1
url = https://github.com/Soft/xcolor
arch = x86_64
@@ -9,8 +9,7 @@ pkgbase = xcolor
makedepends = cargo
makedepends = python
depends = libxcb
- source = https://github.com/Soft/xcolor/archive/0.4.0.tar.gz
- md5sums = 614f6c07a1c6ee6da065e7d1d68fd861
+ source = https://github.com/Soft/xcolor/archive/0.5.0.tar.gz
+ sha256sums = 23cdfd4e87c6f38000e36704bc83e157d6476967892b0e26eee55ed743076400
pkgname = xcolor
-
diff --git a/PKGBUILD b/PKGBUILD
index f54bbdf..244bc82 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,6 +1,6 @@
# Maintainer: Samuel Laurén <samuel dot lauren at iki dot fi>
pkgname=xcolor
-pkgver=0.4.0
+pkgver=0.5.0
pkgrel=1
pkgdesc="Lightweight color picker for X11"
arch=(x86_64)
@@ -9,7 +9,7 @@ license=(MIT)
depends=("libxcb")
makedepends=("rust" "cargo" "python")
source=("https://github.com/Soft/xcolor/archive/${pkgver}.tar.gz")
-md5sums=("614f6c07a1c6ee6da065e7d1d68fd861")
+sha256sums=('23cdfd4e87c6f38000e36704bc83e157d6476967892b0e26eee55ed743076400')
build() {
@@ -21,4 +21,5 @@ package() {
cd "$srcdir/xcolor-${pkgver}"
install -D -m755 -D target/release/xcolor "$pkgdir/usr/bin/xcolor"
install -D -m644 -D man/xcolor.1 "$pkgdir/usr/share/man/man1/xcolor.1"
+ install -D -m644 -D LICENSE "$pkgdir/usr/share/licenses/${pkgname}/LICENSE"
}
When I'm using a graphical tablet (Wacom CTL-471) color isn't printed on click. With mouse it works ok.
I suppose this is because tablet's pen is almost impossible to keep still and so it continuously updates the cursor position. When I move up the pen so it no longer is seen by the tablet and the cursor stops, and then execute xdottool click 1
, xcolor is succesfully prints the color.
Probably it's the same issue as #32.
I tried both -s primary
and -s secondary
, but xcolor doesn't seem to save anything to the selection. I'm using Ubuntu 18.04 with Xfce.
I am facing an error while installing it through cargo, and even when trying to build the makefile. Here is the error I am facing with cargo install xcolor
-
Updating crates.io index
Installing xcolor v0.5.1
Compiling libc v0.2.117
Compiling autocfg v1.0.1
Compiling pkg-config v0.3.24
Compiling unicode-width v0.1.9
Compiling cfg-if v1.0.0
Compiling log v0.4.14
Compiling strsim v0.8.0
Compiling bitflags v1.3.2
Compiling vec_map v0.8.2
Compiling version_check v0.9.4
Compiling memchr v2.4.1
Compiling ansi_term v0.12.1
Compiling anyhow v1.0.53
Compiling minimal-lexical v0.2.1
Compiling lazy_static v1.4.0
Compiling textwrap v0.11.0
Compiling nom v7.1.0
Compiling memoffset v0.6.5
Compiling x11 v2.19.1
error: failed to run custom build command for `x11 v2.19.1`
Caused by:
process didn't exit successfully: `/tmp/cargo-installBYY04K/release/build/x11-2d181bd4a8edf764/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-env-changed=X11_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=X11_STATIC
cargo:rerun-if-env-changed=X11_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=SYSROOT
cargo:rerun-if-env-changed=X11_STATIC
cargo:rerun-if-env-changed=X11_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
cargo:rustc-link-search=native=/usr/lib/x86_64-linux-gnu
cargo:rustc-link-lib=X11
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=X11_STATIC
cargo:rerun-if-env-changed=X11_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=XCURSOR_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=XCURSOR_STATIC
cargo:rerun-if-env-changed=XCURSOR_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: `"pkg-config" "--libs" "--cflags" "xcursor" "xcursor >= 1.1"` did not exit successfully: exit status: 1
error: could not find system library 'xcursor' required by the 'x11' crate
--- stderr
Package xcursor was not found in the pkg-config search path.
Perhaps you should add the directory containing `xcursor.pc'
to the PKG_CONFIG_PATH environment variable
No package 'xcursor' found
Package xcursor was not found in the pkg-config search path.
Perhaps you should add the directory containing `xcursor.pc'
to the PKG_CONFIG_PATH environment variable
No package 'xcursor' found
', /home/r/.cargo/registry/src/github.com-1ecc6299db9ec823/x11-2.19.1/build.rs:40:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to compile `xcolor v0.5.1`, intermediate artifacts can be found at `/tmp/cargo-installBYY04K`
Caused by:
build failed
for
proof:
using the fact that
be applied to r, g, b, (B)lack and (W)hite, which gives us:
with the following possible implementation for color::is_dark(self: ARGB)
:
pub fn is_dark(self) -> bool {
// should cast to a larger integer type to avoid overflow
2 * (self.r + self.g + self.b)
< (Self::WHITE.r + Self::BLACK.r)
+ (Self::WHITE.g + Self::BLACK.g)
+ (Self::WHITE.b + Self::BLACK.b)
}
considering
pub fn is_dark(self) -> bool {
2 * (self.r as u32 + self.g as u32 + self.b as u32) < 3 * 0xff
}
It would be nice to better support HiDPi screens. This mostly means scaling the preview window appropriately.
When trying to launch xcolor from the GNOME's Activities overview, nothing happens. Upon inspecting the system journal, however, you can see this message:
$ journalctl -b
< ... >
May 07 18:25:38 arch xcolor.desktop[164542]: error: Could not grab pointer
System information:
It would be handy to display the rgb value as a notification, when its in clipboard.
Maybe like this:
notify-send "XColor" --icon=xcolor "$(echo -e "RGB value\n#65c9ff\ncopied to clipboard.")"
Is there a way to specify multiple output formats?
For example, I would like the tool to return both, the hex and the rgb value of the color.
I would imagine a command like xcolor -f hex,rgb
, providing both values as output.
It does not seem like that functionality is there yet, would it be possible to add this?
will it ever be possible to use this on wayland?
install cargo:
sudo apt install cargo
a) create the binary:
git clone https://github.com/Soft/xcolor
cd xcolor
make
after that the build binary is located in ./target/release/xcolor
b) or create a deb file:
cargo install cargo-deb
git clone https://github.com/Soft/xcolor
cd xcolor
cargo deb
after that the build deb file is located in ./target/debian/xcolor_0.5.0_amd64.deb
Hi there, Thanks for this wonderful software!
I was wondering if you had plans for a new release soon? The last release was over 3 years ago and it seems that there has been some major improvements since then.
I went to install xcolor
on the AUR and realized that not all of the settings documented in the README were available
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.