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

Update links on every refresh #457

Merged
merged 2 commits into from
Feb 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/ui/pages/drive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,6 @@ impl ResDrive {
imp.set_tab_detail_string(&drive_data.inner.block_device);
}

if let Ok(link) = drive.link() {
imp.link.set_subtitle(&link.to_string());
} else {
imp.link.set_subtitle(&i18n("N/A"));
}

imp.old_stats
.borrow_mut()
.clone_from(&drive_data.disk_stats);
Expand All @@ -289,6 +283,7 @@ impl ResDrive {
removable,
disk_stats,
capacity,
link,
} = drive_data;

let time_passed = SystemTime::now()
Expand Down Expand Up @@ -428,6 +423,12 @@ impl ResDrive {
imp.removable.set_subtitle(&i18n("N/A"));
}

if let Ok(link) = link {
imp.link.set_subtitle(&link.to_string());
} else {
imp.link.set_subtitle(&i18n("N/A"));
}

self.set_property(
"tab_usage_string",
// Translators: This is an abbreviation for "Read" and "Write". This is displayed in the sidebar so your
Expand Down
13 changes: 7 additions & 6 deletions src/ui/pages/gpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,6 @@ impl ResGPU {
imp.encode_decode_usage.set_visible(true);
}

if let Ok(link) = gpu.link() {
imp.link.set_subtitle(&link.to_string());
} else {
imp.link.set_subtitle(&i18n("N/A"));
}

if let Ok(model_name) = gpu.name() {
imp.set_tab_detail_string(&model_name);
}
Expand Down Expand Up @@ -293,6 +287,7 @@ impl ResGPU {
power_usage,
power_cap,
power_cap_max,
link,
nvidia: _,
} = gpu_data;

Expand Down Expand Up @@ -435,6 +430,12 @@ impl ResGPU {
imp.temperature.set_subtitle(&i18n("N/A"));
}

if let Some(link) = link {
imp.link.set_subtitle(&link.to_string());
} else {
imp.link.set_subtitle(&i18n("N/A"));
}

self.set_property("tab_usage_string", &usage_percentage_string);
}
}
13 changes: 7 additions & 6 deletions src/ui/pages/npu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,6 @@ impl ResNPU {

imp.driver_used.set_subtitle(&npu.driver());

if let Ok(link) = npu.link() {
imp.link.set_subtitle(&link.to_string());
} else {
imp.link.set_subtitle(&i18n("N/A"));
}

if let Ok(model_name) = npu.name() {
imp.set_tab_detail_string(&model_name);
}
Expand All @@ -252,6 +246,7 @@ impl ResNPU {
power_usage,
power_cap,
power_cap_max,
link,
} = npu_data;

let mut usage_percentage_string = usage_fraction.map_or_else(
Expand Down Expand Up @@ -366,6 +361,12 @@ impl ResNPU {
imp.temperature.set_subtitle(&i18n("N/A"));
}

if let Some(link) = link {
imp.link.set_subtitle(&link.to_string());
} else {
imp.link.set_subtitle(&i18n("N/A"));
}

self.set_property("tab_usage_string", &usage_percentage_string);
}
}
3 changes: 3 additions & 0 deletions src/utils/drive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub struct DriveData {
pub removable: Result<bool>,
pub disk_stats: HashMap<String, usize>,
pub capacity: Result<u64>,
pub link: Result<Link>,
}

impl DriveData {
Expand All @@ -48,6 +49,7 @@ impl DriveData {
let removable = inner.removable();
let disk_stats = inner.sys_stats().unwrap_or_default();
let capacity = inner.capacity();
let link = inner.link();

let drive_data = Self {
inner,
Expand All @@ -56,6 +58,7 @@ impl DriveData {
removable,
disk_stats,
capacity,
link,
};

trace!(
Expand Down
5 changes: 5 additions & 0 deletions src/utils/gpu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ pub struct GpuData {
pub power_cap: Option<f64>,
pub power_cap_max: Option<f64>,

pub link: Option<Link>,

pub nvidia: bool,
}

Expand Down Expand Up @@ -80,6 +82,8 @@ impl GpuData {
let power_cap = gpu.power_cap().ok();
let power_cap_max = gpu.power_cap_max().ok();

let link = gpu.link().ok();

let nvidia = matches!(gpu, Gpu::Nvidia(_));

let gpu_data = Self {
Expand All @@ -95,6 +99,7 @@ impl GpuData {
power_usage,
power_cap,
power_cap_max,
link,
nvidia,
};

Expand Down
5 changes: 5 additions & 0 deletions src/utils/npu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ pub struct NpuData {
pub power_usage: Option<f64>,
pub power_cap: Option<f64>,
pub power_cap_max: Option<f64>,

pub link: Option<Link>,
}

impl NpuData {
Expand All @@ -65,6 +67,8 @@ impl NpuData {
let power_cap = npu.power_cap().ok();
let power_cap_max = npu.power_cap_max().ok();

let link = npu.link().ok();

let npu_data = Self {
pci_slot,
usage_fraction,
Expand All @@ -76,6 +80,7 @@ impl NpuData {
power_usage,
power_cap,
power_cap_max,
link,
};

trace!("Gathered NPU data for {}: {npu_data:?}", pci_slot);
Expand Down