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

maildir block: add configuration "hide_if_total_is_zero" #2113

Open
mervn opened this issue Dec 8, 2024 · 5 comments · May be fixed by #2114
Open

maildir block: add configuration "hide_if_total_is_zero" #2113

mervn opened this issue Dec 8, 2024 · 5 comments · May be fixed by #2114

Comments

@mervn
Copy link

mervn commented Dec 8, 2024

It would be both consistent1 and useful for maildir notifications to only appear when mail is present. I have not seen the source, but it should successfully return nothing if status = 0 and hide_if_total_is_zero = true.

1 The github block has an identical configuration.

@mervn mervn changed the title maildir (block): Add config hide_if_total_is_zero maildir block: add configuration "hide_if_total_is_zero" Dec 8, 2024
@MaxVerevkin
Copy link
Collaborator

You can achieve this by using range argument of the number formatter:

[[block]]
block = "maildir"
format = " $icon $status.eng(range:1..) |"

This may be added to the examples.

@mervn
Copy link
Author

mervn commented Dec 9, 2024

format = " $icon $status.eng(range:1..) |"

This is a solid workaround, but it does not work without $status.

I would like to avoid seeing the status count on the display.
Is there a way to hide $status permanently?

@MaxVerevkin
Copy link
Collaborator

Is there a way to hide $status permanently?

Not yet. I imagine adding an argument to not render a value, something like $icon $status.eng(range:1..,render:false)|. Would that work for you?

I would prefer it over "hide if zero" because it would solve this issue for all blocks at once.

@mervn
Copy link
Author

mervn commented Dec 9, 2024

something like $icon $status.eng(range:1..,render:false)|

I am very happy with this solution. It's consistent (.eng is being used
by the book) and general (as you've noted).

I assume .eng(render:false) will print "" rather than " ". If so, zero
complaints from me.

MaxVerevkin added a commit that referenced this issue Dec 9, 2024
Fixes #2113

Example usage (will show the icon but only if $status >= 1):

```toml
[[block]]
block = "maildir"
format = " $icon $status.eng(range:1..,show:false)|"
```
@MaxVerevkin MaxVerevkin linked a pull request Dec 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@MaxVerevkin @mervn and others