i3status-rust icon indicating copy to clipboard operation
i3status-rust copied to clipboard

Support x:<name> syntax to fetch color definition from .Xresources

Open jkorinth opened this issue 1 year ago • 11 comments

Adds support to retrieve simple color definitions from ~/.Xresources with a new prefix in the color definitions in theme overrides, e.g.,

[theme.overrides]
idle-bg = "x:background"

would look for a line like

*background: #feedda

in ~/.Xresources.

jkorinth avatar Apr 14 '24 11:04 jkorinth

This looks simple enough, so why not.

This feature should be documented here.

~~To make testing easier, I would prefer to have a dedicated function called extract_xresources_colors(content: &str) -> HashMap<String, String>. Then in tests, you will not have to mock read_xresources function, but instead just assert! the contents of the returned hashmap.~~ Edit: I see, you need mocking to test the FromStr impl.

MaxVerevkin avatar Apr 14 '24 13:04 MaxVerevkin

Updated with the suggestions. There's no documentation for the 'hsv:` prefix, but I think that should go into a separate PR.

jkorinth avatar Apr 14 '24 18:04 jkorinth

Btw: errors deserves an overhaul, too, I think. Check out anyhow and thiserror, they eliminate most of the boiler plate.

jkorinth avatar Apr 19 '24 21:04 jkorinth

Btw: errors deserves an overhaul, too, I think. Check out anyhow and thiserror, they eliminate most of the boiler plate.

I know about these crates and we use thiserror already, in same cases. Creating an error enum for each block does not seem practical. We are not using anyhow because in the past Error struct used to contain a block: String field. It no longer does (we now have a separate BlockError for this, which uses thiserror) and I think we can switch to anyhow now.

MaxVerevkin avatar Apr 20 '24 15:04 MaxVerevkin

LGTM. Just needs the CI to be passing.

MaxVerevkin avatar Apr 22 '24 11:04 MaxVerevkin

LGTM. Just needs the CI to be passing.

How do you tell cspell to ignore words?

jkorinth avatar Apr 22 '24 20:04 jkorinth

How do you tell cspell to ignore words?

Edit cspell.yaml

MaxVerevkin avatar Apr 23 '24 06:04 MaxVerevkin

How do you tell cspell to ignore words?

Edit cspell.yaml

Wait - cspell spellchecks not only the docs, but also the code itself?! And not just strings inside, but the full code? 😂

jkorinth avatar Apr 23 '24 19:04 jkorinth

How do you tell cspell to ignore words?

Edit cspell.yaml

Wait - cspell spellchecks not only the docs, but also the code itself?! And not just strings inside, but the full code? 😂

Yea, it is sometimes annoying, but now we have less typos in variable names, etc.

MaxVerevkin avatar Apr 23 '24 19:04 MaxVerevkin

@jkorinth I've pushed a commit simplifying some stuff, can you review and test it?

MaxVerevkin avatar Apr 26 '24 18:04 MaxVerevkin

Sorry, forgot about this. LGTM!

jkorinth avatar Sep 08 '24 11:09 jkorinth