Cleaned up all of the warnings
This commit is contained in:
@@ -5,10 +5,8 @@ pub mod upower;
|
|||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::sync::RwLock;
|
use std::sync::RwLock;
|
||||||
use std::{cell::RefCell, rc::Rc, sync::Arc};
|
use std::{cell::RefCell, rc::Rc, sync::Arc};
|
||||||
use std::cmp::min;
|
|
||||||
use std::os::linux::raw::stat;
|
|
||||||
use palette::convert::FromColorUnclamped;
|
use palette::convert::FromColorUnclamped;
|
||||||
use palette::{Blend, FromColor, IntoColor, LinSrgba, Mix, Oklab, Oklaba, Packed, Pixel, Shade, Srgb, Srgba};
|
use palette::{FromColor, LinSrgba, Mix, Oklaba, Shade, Srgba};
|
||||||
use wayland_client::{
|
use wayland_client::{
|
||||||
protocol::{wl_output::WlOutput, wl_shm, wl_surface::WlSurface},
|
protocol::{wl_output::WlOutput, wl_shm, wl_surface::WlSurface},
|
||||||
Attached, Main,
|
Attached, Main,
|
||||||
@@ -32,6 +30,7 @@ pub struct PowerState {
|
|||||||
/// True if line power is available.
|
/// True if line power is available.
|
||||||
charging: bool,
|
charging: bool,
|
||||||
/// Time to full charge/empty, in seconds
|
/// Time to full charge/empty, in seconds
|
||||||
|
#[allow(unused)] // TODO: actually use this to display the time remaining
|
||||||
time_remaining: f32,
|
time_remaining: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +226,7 @@ impl Drop for Surface {
|
|||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
|
|
||||||
let mut app_state = AppState::default();
|
let app_state = AppState::default();
|
||||||
|
|
||||||
// Spawn upower watcher
|
// Spawn upower watcher
|
||||||
let upower_channel = {
|
let upower_channel = {
|
||||||
@@ -284,7 +283,6 @@ fn main() -> anyhow::Result<()> {
|
|||||||
let mut event_loop = calloop::EventLoop::<()>::try_new().expect("Failed to start event loop");
|
let mut event_loop = calloop::EventLoop::<()>::try_new().expect("Failed to start event loop");
|
||||||
|
|
||||||
let surfaces_handle = Rc::clone(&surfaces);
|
let surfaces_handle = Rc::clone(&surfaces);
|
||||||
let power_state_handle = Arc::clone(&app_state.display_status);
|
|
||||||
event_loop.handle().insert_source(
|
event_loop.handle().insert_source(
|
||||||
upower_channel,
|
upower_channel,
|
||||||
move |_, _, _| {
|
move |_, _, _| {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ use std::collections::HashMap;
|
|||||||
use crate::PowerState;
|
use crate::PowerState;
|
||||||
use std::sync::mpsc::SyncSender;
|
use std::sync::mpsc::SyncSender;
|
||||||
use std::sync::{
|
use std::sync::{
|
||||||
mpsc::{Receiver, Sender},
|
|
||||||
Arc, RwLock,
|
Arc, RwLock,
|
||||||
};
|
};
|
||||||
use upower_dbus;
|
use upower_dbus;
|
||||||
@@ -17,17 +16,6 @@ pub struct PowerReporter {
|
|||||||
pub status: Arc<RwLock<Option<PowerState>>>,
|
pub status: Arc<RwLock<Option<PowerState>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PowerReceiver {
|
|
||||||
receiver: Receiver<()>,
|
|
||||||
status: Arc<RwLock<Option<PowerState>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! catch {
|
|
||||||
($expr:block) => {
|
|
||||||
(|| $expr)()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn spawn_mock(reporter: PowerReporter) -> anyhow::Result<()> {
|
pub fn spawn_mock(reporter: PowerReporter) -> anyhow::Result<()> {
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
*reporter.status.write().unwrap() = Some(PowerState{
|
*reporter.status.write().unwrap() = Some(PowerState{
|
||||||
@@ -54,7 +42,7 @@ pub fn spawn_upower(reporter: PowerReporter) -> anyhow::Result<()> {
|
|||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
let failure = upower_run(reporter, &start_send);
|
let failure = upower_run(reporter, &start_send);
|
||||||
if failure.is_err() {
|
if failure.is_err() {
|
||||||
start_send.send(failure);
|
start_send.send(failure).unwrap();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -101,7 +89,7 @@ fn upower_run(
|
|||||||
.cache_properties(zbus::CacheProperties::No)
|
.cache_properties(zbus::CacheProperties::No)
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
let mut prop_changed_iterator = display_proxy.receive_properties_changed()?;
|
let prop_changed_iterator = display_proxy.receive_properties_changed()?;
|
||||||
|
|
||||||
let device_interface_name = zbus::names::InterfaceName::from_static_str("org.freedesktop.UPower.Device").unwrap();
|
let device_interface_name = zbus::names::InterfaceName::from_static_str("org.freedesktop.UPower.Device").unwrap();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user