1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-08-17 14:51:04 +02:00

refactor: upgrade to zbus v5

Also drops the deprecated `upower-dbus` crate
This commit is contained in:
Jake Stanger 2025-02-08 01:54:17 +00:00
parent 75375aa341
commit 63f5954837
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
10 changed files with 388 additions and 336 deletions

View file

@ -4,10 +4,10 @@ use gtk::{prelude::*, Button};
use gtk::{Label, Orientation};
use serde::Deserialize;
use tokio::sync::{broadcast, mpsc};
use upower_dbus::BatteryState;
use zbus;
use zbus::fdo::PropertiesProxy;
use crate::clients::upower::BatteryState;
use crate::config::CommonConfig;
use crate::gtk_helpers::{IronbarGtkExt, IronbarLabelExt};
use crate::image::ImageProvider;
@ -59,7 +59,7 @@ pub struct UpowerProperties {
time_to_empty: i64,
}
impl Module<gtk::Button> for UpowerModule {
impl Module<Button> for UpowerModule {
type SendMessage = UpowerProperties;
type ReceiveMessage = ();
@ -84,23 +84,23 @@ impl Module<gtk::Button> for UpowerModule {
let properties = display_proxy.get_all(device_interface_name.clone()).await?;
let percentage = *properties["Percentage"]
let percentage = properties["Percentage"]
.downcast_ref::<f64>()
.expect("expected percentage: f64 in HashMap of all properties");
let icon_name = properties["IconName"]
.downcast_ref::<str>()
.downcast_ref::<&str>()
.expect("expected IconName: str in HashMap of all properties")
.to_string();
let state = u32_to_battery_state(
*properties["State"]
properties["State"]
.downcast_ref::<u32>()
.expect("expected State: u32 in HashMap of all properties"),
)
.unwrap_or(BatteryState::Unknown);
let time_to_full = *properties["TimeToFull"]
let time_to_full = properties["TimeToFull"]
.downcast_ref::<i64>()
.expect("expected TimeToFull: i64 in HashMap of all properties");
let time_to_empty = *properties["TimeToEmpty"]
let time_to_empty = properties["TimeToEmpty"]
.downcast_ref::<i64>()
.expect("expected TimeToEmpty: i64 in HashMap of all properties");
let mut properties = UpowerProperties {
@ -128,7 +128,7 @@ impl Module<gtk::Button> for UpowerModule {
}
"IconName" => {
properties.icon_name = changed_value
.downcast_ref::<str>()
.downcast_ref::<&str>()
.expect("expected IconName to be str")
.to_string();
}