Cleaned up all of the warnings

This commit is contained in:
2022-05-04 19:04:52 +02:00
parent 9854fa2a90
commit ff48e5c1dd
2 changed files with 5 additions and 19 deletions

View File

@@ -5,10 +5,8 @@ pub mod upower;
use std::cell::Cell;
use std::sync::RwLock;
use std::{cell::RefCell, rc::Rc, sync::Arc};
use std::cmp::min;
use std::os::linux::raw::stat;
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::{
protocol::{wl_output::WlOutput, wl_shm, wl_surface::WlSurface},
Attached, Main,
@@ -32,6 +30,7 @@ pub struct PowerState {
/// True if line power is available.
charging: bool,
/// Time to full charge/empty, in seconds
#[allow(unused)] // TODO: actually use this to display the time remaining
time_remaining: f32,
}
@@ -227,7 +226,7 @@ impl Drop for Surface {
fn main() -> anyhow::Result<()> {
let mut app_state = AppState::default();
let app_state = AppState::default();
// Spawn upower watcher
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 surfaces_handle = Rc::clone(&surfaces);
let power_state_handle = Arc::clone(&app_state.display_status);
event_loop.handle().insert_source(
upower_channel,
move |_, _, _| {

View File

@@ -2,7 +2,6 @@ use std::collections::HashMap;
use crate::PowerState;
use std::sync::mpsc::SyncSender;
use std::sync::{
mpsc::{Receiver, Sender},
Arc, RwLock,
};
use upower_dbus;
@@ -17,17 +16,6 @@ pub struct PowerReporter {
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<()> {
std::thread::spawn(move || {
*reporter.status.write().unwrap() = Some(PowerState{
@@ -54,7 +42,7 @@ pub fn spawn_upower(reporter: PowerReporter) -> anyhow::Result<()> {
std::thread::spawn(move || {
let failure = upower_run(reporter, &start_send);
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)
.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();