fixed some overhead + updated readme
This commit is contained in:
+5
-6
@@ -7,11 +7,10 @@ use std::process::Command;
|
||||
|
||||
pub struct BudsModule;
|
||||
|
||||
const MAC_ADDRESS: &str = "B4:23:A2:09:D3:53";
|
||||
|
||||
impl WaybarModule for BudsModule {
|
||||
fn run(&self, _config: &Config, _state: &SharedState, args: &[&str]) -> Result<WaybarOutput> {
|
||||
fn run(&self, config: &Config, _state: &SharedState, args: &[&str]) -> Result<WaybarOutput> {
|
||||
let action = args.first().unwrap_or(&"show");
|
||||
let mac = &config.buds.mac;
|
||||
|
||||
match *action {
|
||||
"cycle_anc" => {
|
||||
@@ -33,7 +32,7 @@ impl WaybarModule for BudsModule {
|
||||
});
|
||||
}
|
||||
"connect" => {
|
||||
Command::new("bluetoothctl").args(["connect", MAC_ADDRESS]).status()?;
|
||||
Command::new("bluetoothctl").args(["connect", mac]).status()?;
|
||||
return Ok(WaybarOutput {
|
||||
text: String::new(),
|
||||
tooltip: None,
|
||||
@@ -42,7 +41,7 @@ impl WaybarModule for BudsModule {
|
||||
});
|
||||
}
|
||||
"disconnect" => {
|
||||
Command::new("bluetoothctl").args(["disconnect", MAC_ADDRESS]).status()?;
|
||||
Command::new("bluetoothctl").args(["disconnect", mac]).status()?;
|
||||
return Ok(WaybarOutput {
|
||||
text: String::new(),
|
||||
tooltip: None,
|
||||
@@ -54,7 +53,7 @@ impl WaybarModule for BudsModule {
|
||||
}
|
||||
|
||||
// Check if connected
|
||||
let bt_info = Command::new("bluetoothctl").args(["info", MAC_ADDRESS]).output()?;
|
||||
let bt_info = Command::new("bluetoothctl").args(["info", mac]).output()?;
|
||||
let bt_str = String::from_utf8_lossy(&bt_info.stdout);
|
||||
|
||||
if !bt_str.contains("Connected: yes") {
|
||||
|
||||
@@ -41,7 +41,6 @@ impl HardwareDaemon {
|
||||
let load_avg = System::load_average();
|
||||
let uptime = System::uptime();
|
||||
|
||||
// Fast O(1) process count by reading loadavg instead of heavy sysinfo process refresh
|
||||
let mut process_count = 0;
|
||||
if let Ok(loadavg_str) = std::fs::read_to_string("/proc/loadavg") {
|
||||
let parts: Vec<&str> = loadavg_str.split_whitespace().collect();
|
||||
@@ -73,7 +72,6 @@ impl HardwareDaemon {
|
||||
fn poll_gpu(&mut self, gpu: &mut crate::state::GpuState) {
|
||||
gpu.active = false;
|
||||
|
||||
// Fast path: if we already detected NVIDIA, don't fallback to AMD/Intel scanning
|
||||
if self.gpu_vendor.as_deref() == Some("NVIDIA") || self.gpu_vendor.is_none() {
|
||||
if let Ok(output) = std::process::Command::new("nvidia-smi")
|
||||
.args(["--query-gpu=utilization.gpu,memory.used,memory.total,temperature.gpu,name", "--format=csv,noheader,nounits"])
|
||||
@@ -99,7 +97,6 @@ impl HardwareDaemon {
|
||||
}
|
||||
}
|
||||
|
||||
// Fast path: if we detected AMD or Intel, scan sysfs
|
||||
if self.gpu_vendor.as_deref() == Some("AMD") || self.gpu_vendor.as_deref() == Some("Intel") || self.gpu_vendor.is_none() {
|
||||
for i in 0..=3 {
|
||||
let base = format!("/sys/class/drm/card{}/device", i);
|
||||
|
||||
Reference in New Issue
Block a user