greshake / i3status-rust

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

net inactive_format is not used when the interface is down and `$ip` placeholder not found #1917

Open kevenwyld opened 1 year ago

kevenwyld commented 1 year ago

I'm not sure if this is intentional or not however inactive_format seems not to be used when the interface is down. In my case I have a vpn which I turn on and off as needed. It is defined as the following block:

[[block]]
block = "net"
device = "vpn0"
format = "$icon UP"
inactive_format = "$icon DOWN"

If the state of the adapter is down:

] > ip addr show dev vpn0
10: vpn0: <NO-CARRIER,POINTOPOINT,MULTICAST,NOARP,UP> mtu 1390 qdisc fq_codel state DOWN group default qlen 500
    link/none
    inet6 fe80::8cb5:e9db:d6a3:1d8/64 scope link stable-privacy
       valid_lft forever preferred_lft forever

i3status-rs reports:

  {
    "full_text": " UP",
    "color": "#C1C1C1FF",
    "background": "#06060FFF",
    "name": "10",
    "instance": "10:",
    "separator": false,
    "separator_block_width": 0,
    "markup": "pango"
  },

This also seems to cause some issues with the $ip placeholder which reports Failed to render full text (Cause: Placeholder 'ip' not found)

Everything works fine if I bring the vpn up though.

MaxVerevkin commented 1 year ago

Huh, this must be because we special-case vpn interfaces to always report "up", which was the case since the initial vpn support (#350)... https://github.com/greshake/i3status-rust/blob/2186e7bd32282af5fa54522e52ec9faa7f4fffae/src/netlink.rs#L103-L108

MaxVerevkin commented 1 year ago

I wonder if this hack can be removed since we have eed699a.