Skip to content
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

Add a general and per-module default color configuration #284

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Gravemind
Copy link
Contributor

@Gravemind Gravemind commented May 29, 2018

Add a new color_default configuration to emit a per-module default color.

If left unspecified, you get the old behavior: the non-good/degraded/bad state does not emit any color, and so you get your bar program's default color.

If color_default is specified, in general for all modules, or per-module in their respective sections, then the module will emit this color when in non-good/degraded/bad state.

Any color (color_default, color_good etc.) can be set to an empty string to disable the color, reverting to the bar program default color.

Notes on the source code changes:

  • Replaced START_COLOR/END_COLOR with a variable outcolor (similar to outwalk), typed with a enum output_color_t. I think it's easier to play with the color now, and it makes it clearer it's for the entire module (as opposed to starting a color mid-sentence).
  • This effectively adds a 4th state to good/bad/degraded. I thought about merging default and good state (e.g. good state by default), but some modules seem to differentiate between the default and the good state.

@Gravemind
Copy link
Contributor Author

For what it's worth, I still use it, and, anyway, I don't mind maintaining it just for me...

I thought my last description/commit message was not great, so I reworded it to something better (I hope):


The significant code change was to replace the START_COLOR and END_COLOR macros by an enum and a variable outcolor used similarly to outwalk (see OUTPUT_FULL_TEXT).

A few improvements have been made from there:

  1. allow any color_* config to be set to an empty string to disable it (i.e. force remove the color from the output) (also useful for 2.).

  2. add a color_default config to general and to all modules/sections, so the default/normal color can be customized everywhere (color of tztime, "normal" color of memory, etc...). Unspecified by default, so same as old behavior (no color output).

  3. fix per-section color emission for output_format other than i3bar.

Replace the macros `START_COLOR` and `END_COLOR` by an enum and a variable
`outcolor` (similar to `outwalk`, see `OUTPUT_FULL_TEXT`).

This allowed for the addition of a couple user-side features:

Add a new `color_default` config to the general and to all modules. So the
default color can now be customized per-module. An unspecified or empty value
means no color (same as old behavior).

Any `color_*` config (in general or modules) can now be set to an empty
string to disable it (no color emitted).
@Gravemind Gravemind changed the title Add default color and minor color enhancements Add a general and per-module default color configuration Dec 31, 2023
@Gravemind
Copy link
Contributor Author

I changed the title and description again.

FWIW I still thinks this is a good change, for users, and for the code.

I am open to suggestions. If you think this is outside the scope of i3status, I'm ok with closing this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants