greshake / i3status-rust

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

amd_gpu: improve the error when a device does not exist #2034

Closed heitorPB closed 3 months ago

heitorPB commented 3 months ago

I updated my system and got the 0.33.0 i3status-rs, but I saw a red block on my status bar saying Failed to read gpu_busy_percent.

My config for this block is:

[[block]]
block = "amd_gpu"
device = "card0"
format_alt = "$icon $vram_used.eng(w:2,u:B,p:Mi)/$vram_total.eng(w:1,u:B,p:Gi)"
interval = 2

If I manually run i3status-rs, the JSON for this block is this:

{
  "full_text": "Failed to read gpu_busy_percent ",
  "color": "#002B36FF",
  "background": "#DC322FFF",
  "name": "4",
  "instance": "4:",
  "separator": false,
  "separator_block_width": 0,
  "markup": "pango"
}
MaxVerevkin commented 3 months ago

This block haven't received any changes in the last few versions. What is the output of ls /dev/dri? A driver/kernel update changed the card name from "card0" to "card1" some time ago, and maybe you've updated the kernel together with i3status-rs?

If this is the case, the error message can be definitely improved.

heitorPB commented 3 months ago

Oh, interesting. I changed from card0 to card1 and stuff is back into normal.

I see card1 in /dev/dri and /sys/class/drm.

If this is the case, the error message can be definitely improved.

Device {device} not found would be great. Could you mentor me on what needs to be done to implement this?

MaxVerevkin commented 3 months ago

Sure, it should be pretty easy. A check needs to be added to Device::new. Something like if !path.exists() { Err(Error::new(format!("Device {name} not found"))) } else { Ok(Self { path }) }