mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-27 07:34:27 +02:00
other: support hw.temperature-based temps on FreeBSD (#1024)
* other: support hw.temperature-based temps for FreeBSD * update changelog * enable sysctl always for freebsd
This commit is contained in:
parent
2a1c4104fd
commit
6d15f01009
@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
- [#1016](https://github.com/ClementTsang/bottom/pull/1016): Add support for displaying process usernames on Windows.
|
- [#1016](https://github.com/ClementTsang/bottom/pull/1016): Add support for displaying process usernames on Windows.
|
||||||
- [#1022](https://github.com/ClementTsang/bottom/pull/1022): Support three-character hex colour strings for styling.
|
- [#1022](https://github.com/ClementTsang/bottom/pull/1022): Support three-character hex colour strings for styling.
|
||||||
|
- [#1024](https://github.com/ClementTsang/bottom/pull/1024): Support FreeBSD temperature sensors based on `hw.temperature`.
|
||||||
|
|
||||||
## Changes
|
## Changes
|
||||||
|
|
||||||
|
23
Cargo.lock
generated
23
Cargo.lock
generated
@ -567,6 +567,18 @@ version = "1.6.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
|
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "enum-as-inner"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116"
|
||||||
|
dependencies = [
|
||||||
|
"heck",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "errno"
|
name = "errno"
|
||||||
version = "0.2.8"
|
version = "0.2.8"
|
||||||
@ -786,6 +798,12 @@ version = "0.12.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "heck"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heim"
|
name = "heim"
|
||||||
version = "0.1.0-rc.1"
|
version = "0.1.0-rc.1"
|
||||||
@ -1644,12 +1662,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sysctl"
|
name = "sysctl"
|
||||||
version = "0.5.2"
|
version = "0.5.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f99d037b2bef227ab8963f4b0acc33ecbb1f9a2e7365add7789372b387ec19e1"
|
checksum = "ed66d6a2ccbd656659289bc90767895b7abbdec897a0fc6031aca3ed1cb51d3e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
|
"enum-as-inner",
|
||||||
"libc",
|
"libc",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
|
20
Cargo.toml
20
Cargo.toml
@ -63,13 +63,12 @@ strip = false
|
|||||||
battery = ["starship-battery"]
|
battery = ["starship-battery"]
|
||||||
gpu = ["nvidia"]
|
gpu = ["nvidia"]
|
||||||
nvidia = ["nvml-wrapper"]
|
nvidia = ["nvml-wrapper"]
|
||||||
zfs = ["sysctl"]
|
|
||||||
|
|
||||||
# The features we use by default.
|
# The features we use by default.
|
||||||
default = ["fern", "log", "battery", "gpu", "zfs"]
|
default = ["fern", "log", "battery", "gpu"]
|
||||||
|
|
||||||
# The features we use on deploy. Logging is not included as that is primarily (for now) just for debugging locally.
|
# The features we use on deploy. Logging is not included as that is primarily (for now) just for debugging locally.
|
||||||
deploy = ["battery", "gpu", "zfs"]
|
deploy = ["battery", "gpu"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.57"
|
anyhow = "1.0.57"
|
||||||
@ -109,7 +108,13 @@ unicode-width = "0.1.10"
|
|||||||
libc = "0.2.124"
|
libc = "0.2.124"
|
||||||
|
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
heim = { version = "0.1.0-rc.1", features = ["cpu", "disk", "memory", "net", "sensors"] }
|
heim = { version = "0.1.0-rc.1", features = [
|
||||||
|
"cpu",
|
||||||
|
"disk",
|
||||||
|
"memory",
|
||||||
|
"net",
|
||||||
|
"sensors",
|
||||||
|
] }
|
||||||
procfs = { version = "0.14.2", default-features = false }
|
procfs = { version = "0.14.2", default-features = false }
|
||||||
smol = "1.2.5"
|
smol = "1.2.5"
|
||||||
|
|
||||||
@ -119,13 +124,16 @@ mach2 = "0.4.1"
|
|||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
heim = { version = "0.1.0-rc.1", features = ["cpu", "disk", "memory"] }
|
heim = { version = "0.1.0-rc.1", features = ["cpu", "disk", "memory"] }
|
||||||
windows = { version = "0.44.0", features = ["Win32_System_Threading", "Win32_Foundation"] }
|
windows = { version = "0.44.0", features = [
|
||||||
|
"Win32_System_Threading",
|
||||||
|
"Win32_Foundation",
|
||||||
|
] }
|
||||||
|
|
||||||
winapi = "0.3.9"
|
winapi = "0.3.9"
|
||||||
|
|
||||||
[target.'cfg(target_os = "freebsd")'.dependencies]
|
[target.'cfg(target_os = "freebsd")'.dependencies]
|
||||||
serde_json = { version = "1.0.82" }
|
serde_json = { version = "1.0.82" }
|
||||||
sysctl = { version = "0.5.2", optional = true }
|
sysctl = { version = "0.5.4" }
|
||||||
filedescriptor = "0.8.2"
|
filedescriptor = "0.8.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
@ -38,5 +38,30 @@ pub fn get_temperature_data(
|
|||||||
super::nvidia::add_nvidia_data(&mut temperature_vec, temp_type, filter)?;
|
super::nvidia::add_nvidia_data(&mut temperature_vec, temp_type, filter)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For RockPro64 boards on FreeBSD, they apparently use "hw.temperature" for sensors.
|
||||||
|
#[cfg(target_os = "freebsd")]
|
||||||
|
{
|
||||||
|
use sysctl::Sysctl;
|
||||||
|
|
||||||
|
const KEY: &str = "hw.temperature";
|
||||||
|
if let Ok(root) = sysctl::Ctl::new(KEY) {
|
||||||
|
for ctl in sysctl::CtlIter::below(root).flatten() {
|
||||||
|
if let (Ok(name), Ok(temp)) = (ctl.name(), ctl.value()) {
|
||||||
|
if let Some(temp) = temp.as_temperature() {
|
||||||
|
temperature_vec.push(TempHarvest {
|
||||||
|
name,
|
||||||
|
temperature: match temp_type {
|
||||||
|
TemperatureType::Celsius => temp.celsius(),
|
||||||
|
TemperatureType::Kelvin => temp.kelvin(),
|
||||||
|
TemperatureType::Fahrenheit => temp.fahrenheit(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Should we instead use a hashmap -> vec to skip dupes?
|
||||||
Ok(Some(temperature_vec))
|
Ok(Some(temperature_vec))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user