Skip to content
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
28 changes: 1 addition & 27 deletions src/channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,6 @@ pub enum TempSource {
impl TempSource {
pub const ALL: [TempSource; 3] = [TempSource::Cpu, TempSource::Gpu, TempSource::Hottest];

/// Short name for CLI and logs.
pub fn id(self) -> &'static str {
match self {
TempSource::Cpu => "cpu",
TempSource::Gpu => "gpu",
TempSource::Hottest => "hottest",
}
}

pub fn from_id(id: &str) -> Option<Self> {
Self::ALL.into_iter().find(|s| s.id() == id)
}

pub fn label(self) -> &'static str {
match self {
TempSource::Cpu => "CPU",
Expand Down Expand Up @@ -531,7 +518,7 @@ impl GpuTemp {
} else if self.nvidia_paused() {
Vec::new()
} else {
match nvidia_temperatures() {
match nvidia_query("temperature.gpu") {
Ok(temps) => temps,
Err(e) => {
// Back off rather than calling a failing nvidia-smi every
Expand Down Expand Up @@ -600,11 +587,6 @@ impl GpuTemp {
}
}

/// Temperatures in °C of every NVIDIA GPU, via nvidia-smi.
fn nvidia_temperatures() -> std::io::Result<Vec<f32>> {
nvidia_query("temperature.gpu")
}

/// One numeric nvidia-smi query field for every NVIDIA GPU.
fn nvidia_query(field: &str) -> std::io::Result<Vec<f32>> {
let output = Command::new("nvidia-smi")
Expand Down Expand Up @@ -766,14 +748,6 @@ mod tests {
assert!(!fan.is_missing());
}

#[test]
fn temp_source_ids_round_trip() {
for source in TempSource::ALL {
assert_eq!(TempSource::from_id(source.id()), Some(source));
}
assert_eq!(TempSource::from_id("bogus"), None);
}

#[test]
fn missing_sensor_falls_back_to_the_other() {
assert_eq!(source_temp(TempSource::Gpu, Some(40.0), None), Some(40.0));
Expand Down
Loading
Loading