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

Toggle critical_bg not working #1923

Closed
eric-hansen opened this issue Jul 21, 2023 · 3 comments · Fixed by #1974
Closed

Toggle critical_bg not working #1923

eric-hansen opened this issue Jul 21, 2023 · 3 comments · Fixed by #1974

Comments

@eric-hansen
Copy link

eric-hansen commented Jul 21, 2023

From my understanding based on here: https://github.com/greshake/i3status-rust/blob/v0.31.8/src/blocks/toggle.rs#L129

If the status is "on" then idle_bg is used, and if the status is "off" then critical_bg is used.

The determintor from command_state is whether the resulting command has text or if it's an empty string (https://github.com/greshake/i3status-rust/blob/v0.31.8/src/blocks/toggle.rs#L20).

However, the tokio docs, if I'm reading it correctly, says that it's based on the exit code.

I'm not familiar w/ tokio and only a beginner at Rust, so maybe I'm missing something here, but the critical_bg override is never applied when command_state returns an empty string or has exit code of 1.

Here's my current block:

[[block]]
block = "toggle"
format = " $icon "
command_state = "nmcli connection show | grep wg0 | awk '{print $4}' | grep -v 'wg0'"
command_on = "nmcli connection down wg0"
command_off = "nmcli connection up wg0"
[block.theme_overrides]
idle_bg="#005500"
critical_bg="#000000"

What I've also done is move the state command to a shell script and either do exit 0 if the awk value == wg0 or exit 1 if it's not.

image

So what I would expect to see is when the toggle is in this state, the bg is a red color. But instead it stays in idle bg regardless.

The toggle works, so the commands are fine and I can see it reflect in the NetworkManager applet and in the output of nmcli. So it's more so something is not working when trying to set the color.

@MaxVerevkin
Copy link
Collaborator

critical_bg is used when command_{on,off} fails.

@eric-hansen
Copy link
Author

eric-hansen commented Jul 23, 2023 via email

@MaxVerevkin
Copy link
Collaborator

It is not currently possible, state_{on,off} options must be implemented similar to icon_{on,off}.

softmoth added a commit to softmoth/i3status-rust that referenced this issue Dec 16, 2023
softmoth added a commit to softmoth/i3status-rust that referenced this issue Dec 16, 2023
softmoth added a commit to softmoth/i3status-rust that referenced this issue Dec 17, 2023
softmoth added a commit to softmoth/i3status-rust that referenced this issue Dec 17, 2023
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.

2 participants