greshake / i3status-rust

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

Toggle critical_bg not working #1923

Closed eric-hansen closed 7 months ago

eric-hansen commented 1 year ago

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

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

eric-hansen commented 12 months ago

What would I use then for when command_off succeeds like I'm trying to do

On Sun, Jul 23, 2023, 4:40 PM Max Verevkin @.***> wrote:

criticalbg is used when command{on,off} fails.

— Reply to this email directly, view it on GitHub https://github.com/greshake/i3status-rust/issues/1923#issuecomment-1646954696, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB7DKZYPTCDFYITHPPVYVSTXRWD2HANCNFSM6AAAAAA2S5PO2I . You are receiving this because you authored the thread.Message ID: @.***>

MaxVerevkin commented 12 months ago

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