This commit is contained in:
Daniel Flanagan 2024-02-01 17:38:56 -06:00
parent c8eaf5c045
commit 94999fc93c
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4

View file

@ -4,7 +4,7 @@ use std::{
fmt::Display, fmt::Display,
time::{SystemTime, UNIX_EPOCH}, time::{SystemTime, UNIX_EPOCH},
}; };
use upower_dbus::{BatteryLevel, UPowerProxy}; use upower_dbus::{BatteryLevel, DeviceProxy, UPowerProxy};
use zbus::zvariant::OwnedObjectPath; use zbus::zvariant::OwnedObjectPath;
enum ChargeState { enum ChargeState {
@ -39,7 +39,13 @@ struct BatteryStatus {
rate: EnergyRate, rate: EnergyRate,
} }
type BatteryIdentifier = OwnedObjectPath; impl<'a> From<DeviceProxy<'a>> for BatteryStatus {
fn from(value: DeviceProxy) -> Self {
todo!()
}
}
type BatteryIdentifier = String;
struct Entry { struct Entry {
timestamp: SystemTime, timestamp: SystemTime,
@ -58,12 +64,14 @@ fn main() -> zbus::Result<()> {
let device = upower.get_display_device().await?; let device = upower.get_display_device().await?;
eprintln!("Display Device: {device:?}"); eprintln!("Display Device: {device:?}");
let batteries = HashMap::new();
let does_contain = batteries.contains_key(&device.path().to_string());
println!("Battery Percentage: {:?}", device.percentage().await); println!("Battery Percentage: {:?}", device.percentage().await);
let tracker = Entry { let tracker = Entry {
timestamp: SystemTime::now(), timestamp: SystemTime::now(),
batteries: HashMap::new(), batteries,
}; };
println!("On Battery: {:?}", upower.on_battery().await); println!("On Battery: {:?}", upower.on_battery().await);