mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-16 22:31:03 +02:00
refactor: fix clippy warnings
This commit is contained in:
parent
1d29d61628
commit
f39c4c430e
5 changed files with 43 additions and 50 deletions
|
@ -120,3 +120,40 @@ pub trait Device {
|
|||
#[zbus(property)]
|
||||
fn voltage(&self) -> zbus::Result<f64>;
|
||||
}
|
||||
|
||||
#[proxy(interface = "org.freedesktop.UPower", assume_defaults = true)]
|
||||
pub trait UPower {
|
||||
/// EnumerateDevices method
|
||||
fn enumerate_devices(&self) -> zbus::Result<Vec<zbus::zvariant::OwnedObjectPath>>;
|
||||
|
||||
/// GetCriticalAction method
|
||||
fn get_critical_action(&self) -> zbus::Result<String>;
|
||||
|
||||
/// GetDisplayDevice method
|
||||
#[zbus(object = "Device")]
|
||||
fn get_display_device(&self);
|
||||
|
||||
/// DeviceAdded signal
|
||||
#[zbus(signal)]
|
||||
fn device_added(&self, device: zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>;
|
||||
|
||||
/// DeviceRemoved signal
|
||||
#[zbus(signal)]
|
||||
fn device_removed(&self, device: zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>;
|
||||
|
||||
/// DaemonVersion property
|
||||
#[zbus(property)]
|
||||
fn daemon_version(&self) -> zbus::Result<String>;
|
||||
|
||||
/// LidIsClosed property
|
||||
#[zbus(property)]
|
||||
fn lid_is_closed(&self) -> zbus::Result<bool>;
|
||||
|
||||
/// LidIsPresent property
|
||||
#[zbus(property)]
|
||||
fn lid_is_present(&self) -> zbus::Result<bool>;
|
||||
|
||||
/// OnBattery property
|
||||
#[zbus(property)]
|
||||
fn on_battery(&self) -> zbus::Result<bool>;
|
||||
}
|
|
@ -1,14 +1,13 @@
|
|||
mod device;
|
||||
mod upower;
|
||||
mod dbus;
|
||||
|
||||
use crate::clients::ClientResult;
|
||||
use crate::register_fallible_client;
|
||||
use dbus::UPowerProxy;
|
||||
use std::sync::Arc;
|
||||
use upower::UPowerProxy;
|
||||
use zbus::fdo::PropertiesProxy;
|
||||
use zbus::proxy::CacheProperties;
|
||||
|
||||
pub use device::BatteryState;
|
||||
pub use dbus::BatteryState;
|
||||
|
||||
pub async fn create_display_proxy() -> ClientResult<PropertiesProxy<'static>> {
|
||||
let dbus = Box::pin(zbus::Connection::system()).await?;
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
use super::device::DeviceProxy;
|
||||
/// Originally taken from `upower-dbus` crate
|
||||
/// https://github.com/pop-os/upower-dbus/blob/main/LICENSE
|
||||
// Copyright 2021 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
use zbus::proxy;
|
||||
|
||||
#[proxy(interface = "org.freedesktop.UPower", assume_defaults = true)]
|
||||
pub trait UPower {
|
||||
/// EnumerateDevices method
|
||||
fn enumerate_devices(&self) -> zbus::Result<Vec<zbus::zvariant::OwnedObjectPath>>;
|
||||
|
||||
/// GetCriticalAction method
|
||||
fn get_critical_action(&self) -> zbus::Result<String>;
|
||||
|
||||
/// GetDisplayDevice method
|
||||
#[zbus(object = "Device")]
|
||||
fn get_display_device(&self);
|
||||
|
||||
/// DeviceAdded signal
|
||||
#[zbus(signal)]
|
||||
fn device_added(&self, device: zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>;
|
||||
|
||||
/// DeviceRemoved signal
|
||||
#[zbus(signal)]
|
||||
fn device_removed(&self, device: zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>;
|
||||
|
||||
/// DaemonVersion property
|
||||
#[zbus(property)]
|
||||
fn daemon_version(&self) -> zbus::Result<String>;
|
||||
|
||||
/// LidIsClosed property
|
||||
#[zbus(property)]
|
||||
fn lid_is_closed(&self) -> zbus::Result<bool>;
|
||||
|
||||
/// LidIsPresent property
|
||||
#[zbus(property)]
|
||||
fn lid_is_present(&self) -> zbus::Result<bool>;
|
||||
|
||||
/// OnBattery property
|
||||
#[zbus(property)]
|
||||
fn on_battery(&self) -> zbus::Result<bool>;
|
||||
}
|
|
@ -336,7 +336,7 @@ impl Environment {
|
|||
let handle = env
|
||||
.handles
|
||||
.iter()
|
||||
.find(|handle| handle.info().map_or(false, |info| info.id == id));
|
||||
.find(|handle| handle.info().is_some_and(|info| info.id == id));
|
||||
|
||||
if let Some(handle) = handle {
|
||||
let seat = env.default_seat();
|
||||
|
@ -350,7 +350,7 @@ impl Environment {
|
|||
let handle = env
|
||||
.handles
|
||||
.iter()
|
||||
.find(|handle| handle.info().map_or(false, |info| info.id == id));
|
||||
.find(|handle| handle.info().is_some_and(|info| info.id == id));
|
||||
|
||||
if let Some(handle) = handle {
|
||||
handle.minimize();
|
||||
|
|
|
@ -175,5 +175,5 @@ pub fn receive(offer: &ZwlrDataControlOfferV1, mime_type: String) -> std::io::Re
|
|||
|
||||
offer.receive(mime_type, writefd.as_fd());
|
||||
|
||||
Ok(Receiver::from_owned_fd(readfd)?)
|
||||
Receiver::from_owned_fd(readfd)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue