greshake / i3status-rust

Very resourcefriendly and feature-rich replacement for i3status, written in pure Rust
GNU General Public License v3.0
2.81k stars 472 forks source link

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

Open jkorinth opened 2 months ago

jkorinth commented 2 months ago

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.

MaxVerevkin commented 2 months ago

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.

jkorinth commented 2 months ago

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

jkorinth commented 2 months ago

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

MaxVerevkin commented 2 months ago

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 commented 2 months ago

LGTM. Just needs the CI to be passing.

jkorinth commented 2 months ago

LGTM. Just needs the CI to be passing.

How do you tell cspell to ignore words?

MaxVerevkin commented 2 months ago

How do you tell cspell to ignore words?

Edit cspell.yaml

jkorinth commented 2 months ago

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? 😂

MaxVerevkin commented 2 months ago

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 commented 2 months ago

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