diff --git a/src/buffer.rs b/src/buffer.rs index 8a9200e..6ff7164 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -19,8 +19,8 @@ use nix::{ use memmap2::MmapMut; use wayland_client::{ - protocol::{wl_buffer, wl_shm, wl_shm_pool}, Dispatch, QueueHandle, + protocol::{wl_buffer, wl_shm, wl_shm_pool}, }; use crate::color::Color; diff --git a/src/config.rs b/src/config.rs index 62a6115..c09b990 100644 --- a/src/config.rs +++ b/src/config.rs @@ -6,7 +6,7 @@ use std::sync::{Arc, Mutex}; use crate::{ event::Events, - fonts::{find_font, FontMap}, + fonts::{FontMap, find_font}, widgets::{ Backlight, Battery, Calendar, Clock, Date, HorizontalLayout, IndexedLayout, Interface, InvertedHorizontalLayout, InvertedVerticalLayout, Layout, Line, Margin, PulseAudio, diff --git a/src/draw.rs b/src/draw.rs index a6b8d2f..d21f132 100644 --- a/src/draw.rs +++ b/src/draw.rs @@ -1,7 +1,7 @@ use crate::buffer::BufferView; use crate::{color::Color, fonts::FontRef}; -use rusttype::{point, Scale}; +use rusttype::{Scale, point}; use std::collections::HashMap; struct CachedGlyph { @@ -121,7 +121,7 @@ impl<'a> Font<'a> { return Err(::std::io::Error::new( ::std::io::ErrorKind::Other, format!("glyph for {:} not in cache", ch), - )) + )); } }; glyphs.push(glyph); @@ -154,7 +154,7 @@ impl<'a> Font<'a> { return Err(::std::io::Error::new( ::std::io::ErrorKind::Other, format!("glyph for {:} not in cache", ch), - )) + )); } }; glyphs.push(glyph); @@ -206,7 +206,7 @@ impl<'a> Font<'a> { return Err(::std::io::Error::new( ::std::io::ErrorKind::Other, format!("glyph for {:} not in cache", ch), - )) + )); } }; let width = glyph.advance; @@ -255,7 +255,7 @@ impl<'a> Font<'a> { return Err(::std::io::Error::new( ::std::io::ErrorKind::Other, format!("glyph for {:} not in cache", ch), - )) + )); } }; glyphs.push(glyph); @@ -287,7 +287,7 @@ impl<'a> Font<'a> { return Err(::std::io::Error::new( ::std::io::ErrorKind::Other, format!("glyph for {:} not in cache", ch), - )) + )); } }; glyphs.push(glyph); diff --git a/src/keyboard/mod.rs b/src/keyboard/mod.rs index ef3e446..7d68ee4 100644 --- a/src/keyboard/mod.rs +++ b/src/keyboard/mod.rs @@ -12,12 +12,9 @@ //! calloop event loop. Not doing so will prevent key repetition to work //! (but the rest of the functionnality will not be affected). -use std::{ - default::Default, - os::unix::io::OwnedFd, -}; +use std::{default::Default, os::unix::io::OwnedFd}; -use wayland_client::{protocol::wl_keyboard, WEnum}; +use wayland_client::{WEnum, protocol::wl_keyboard}; use xkbcommon::xkb; pub use xkbcommon::xkb::keysyms; diff --git a/src/keyboard/repeat.rs b/src/keyboard/repeat.rs index 991182b..31c1115 100644 --- a/src/keyboard/repeat.rs +++ b/src/keyboard/repeat.rs @@ -1,11 +1,11 @@ use std::time::Duration; use calloop::{ + EventSource, Poll, PostAction, Readiness, Token, TokenFactory, channel::{self, Channel}, timer::{TimeoutAction, Timer}, - EventSource, Poll, PostAction, Readiness, Token, TokenFactory, }; -use wayland_client::{protocol::wl_keyboard, WEnum}; +use wayland_client::{WEnum, protocol::wl_keyboard}; use super::KeyEvent; @@ -136,7 +136,9 @@ impl EventSource for KeyRepeatSource { let mut next_deadline = deadline; if now - deadline > *rate * 2 { // We're way behind, let's just set a new time - println!("KeyRepeatSource::process_events: More than two repeat cycles behind, resetting"); + println!( + "KeyRepeatSource::process_events: More than two repeat cycles behind, resetting" + ); next_deadline = now + *rate; } else { while next_deadline < now { diff --git a/src/main.rs b/src/main.rs index a2ba0b6..ddc4321 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,8 +12,8 @@ mod widgets; use wayland_client::{Connection, QueueHandle, WaylandSource}; use calloop::{ - timer::{TimeoutAction, Timer}, EventLoop, + timer::{TimeoutAction, Timer}, }; use chrono::{Duration, Local, Timelike}; @@ -30,12 +30,11 @@ use utils::{ use widgets::{Geometry, Widget}; use std::{ - env, + env, fs, fs::File, - fs, - path::Path, io::{BufRead, BufReader, Write}, os::unix::net::{UnixListener, UnixStream}, + path::Path, rc::Rc, thread, }; diff --git a/src/state.rs b/src/state.rs index 8abfd82..6d9acfb 100644 --- a/src/state.rs +++ b/src/state.rs @@ -7,11 +7,11 @@ use std::{ }; use wayland_client::{ + Connection, Dispatch, QueueHandle, WEnum, protocol::{ wl_buffer, wl_callback, wl_compositor, wl_keyboard, wl_pointer, wl_registry, wl_seat, wl_shm, wl_shm_pool, wl_subcompositor, wl_subsurface, wl_surface, }, - Connection, Dispatch, QueueHandle, WEnum, }; use wayland_protocols::{ @@ -141,7 +141,9 @@ impl State { activation.activate(key, surface); let activation_token = activation.get_activation_token(qh, ()); activation_token.commit(); - unsafe { env::remove_var("XDG_ACTIVATION_TOKEN"); } + unsafe { + env::remove_var("XDG_ACTIVATION_TOKEN"); + } } _ => (), } diff --git a/src/utils/desktop.rs b/src/utils/desktop.rs index 5d887b0..657b5fe 100644 --- a/src/utils/desktop.rs +++ b/src/utils/desktop.rs @@ -2,7 +2,7 @@ use std::{ cmp::Ordering, collections::HashSet, error::Error, - fs::{read_to_string, File}, + fs::{File, read_to_string}, hash::{Hash, Hasher}, io::{Error as io_error, ErrorKind}, path::Path, @@ -104,7 +104,10 @@ pub fn load_desktop_files() -> Vec { let mut seen: HashSet = HashSet::new(); for dir in dirs { - for entry in WalkDir::new(format!("{}/applications", dir)).into_iter().flatten() { + for entry in WalkDir::new(format!("{}/applications", dir)) + .into_iter() + .flatten() + { // Entries are often symlinks, so only rule out directories. if entry.file_type().is_dir() || entry.path().extension().and_then(|e| e.to_str()) != Some("desktop") diff --git a/src/widgets/battery.rs b/src/widgets/battery.rs index c67eece..1605b13 100644 --- a/src/widgets/battery.rs +++ b/src/widgets/battery.rs @@ -6,8 +6,8 @@ use std::{ }; use dbus::blocking::{ - stdintf::org_freedesktop_dbus::{Properties, PropertiesPropertiesChanged}, LocalConnection, + stdintf::org_freedesktop_dbus::{Properties, PropertiesPropertiesChanged}, }; use crate::{ @@ -64,7 +64,10 @@ fn battery_present() -> Result> { Ok(present) } -fn monitor(inner: Arc>, events: Arc>) -> Result<(), Box> { +fn monitor( + inner: Arc>, + events: Arc>, +) -> Result<(), Box> { let conn = LocalConnection::new_system()?; let proxy = conn.with_proxy( "org.freedesktop.UPower", diff --git a/src/widgets/calendar.rs b/src/widgets/calendar.rs index ff3c30b..9ede2ff 100644 --- a/src/widgets/calendar.rs +++ b/src/widgets/calendar.rs @@ -323,7 +323,7 @@ impl<'a> Widget for Calendar { y: 0, width: 0, height: 0, - } + }; } x => x, }; @@ -335,7 +335,7 @@ impl<'a> Widget for Calendar { y: 0, width: 0, height: 0, - } + }; } y => y, }; diff --git a/src/widgets/launcher.rs b/src/widgets/launcher.rs index fe24e9e..526eb20 100644 --- a/src/widgets/launcher.rs +++ b/src/widgets/launcher.rs @@ -1,10 +1,10 @@ use std::{ - cmp::{max, min, Ordering}, + cmp::{Ordering, max, min}, collections::HashMap, default::Default, - fs::{read_to_string, File}, + fs::{File, read_to_string}, io::Write, - process::{exit, Command}, + process::{Command, exit}, sync::{Arc, Mutex}, thread, }; @@ -14,18 +14,18 @@ use crate::{ color::Color, event::{Event, Events, PointerButton, PointerEvent}, fonts::FontMap, - keyboard::{keysyms, KeyEvent}, + keyboard::{KeyEvent, keysyms}, utils::{ - desktop::{load_desktop_cache, load_desktop_files, write_desktop_cache, Desktop}, + desktop::{Desktop, load_desktop_cache, load_desktop_files, write_desktop_cache}, xdg, }, widgets::{Geometry, Widget}, }; -use fuzzy_matcher::skim::SkimMatcherV2; use fuzzy_matcher::FuzzyMatcher; +use fuzzy_matcher::skim::SkimMatcherV2; use unicode_segmentation::UnicodeSegmentation; -use wayland_client::{protocol::wl_keyboard, WEnum}; +use wayland_client::{WEnum, protocol::wl_keyboard}; struct Matcher { matches: HashMap, @@ -692,11 +692,7 @@ impl Interface { if line_height == 0 { return; } - let height = self - .inner - .geometry - .height - .saturating_sub(line_height + 8); + let height = self.inner.geometry.height.saturating_sub(line_height + 8); let lines = height / line_height; let offset = height % line_height; @@ -847,7 +843,7 @@ impl Widget for Interface { #[cfg(test)] mod tests { - use super::{strip_field_codes, Prompt, PromptMode}; + use super::{Prompt, PromptMode, strip_field_codes}; #[test] fn prompt_cursor_is_grapheme_based() { diff --git a/src/widgets/layout.rs b/src/widgets/layout.rs index 21f6c18..47ff3a7 100644 --- a/src/widgets/layout.rs +++ b/src/widgets/layout.rs @@ -113,7 +113,7 @@ impl Layout for VerticalLayout { pub trait WidgetUpdater { fn geometry_update(&mut self, idx: usize, fonts: &mut FontMap, geometry: &Geometry) - -> Geometry; + -> Geometry; fn minimum_size(&mut self, idx: usize, fonts: &mut FontMap) -> Geometry; } diff --git a/src/widgets/pulseaudio.rs b/src/widgets/pulseaudio.rs index 9879529..9503f8a 100644 --- a/src/widgets/pulseaudio.rs +++ b/src/widgets/pulseaudio.rs @@ -26,13 +26,13 @@ fn monitor( use libpulse_binding::{ callbacks::ListResult, context::{ - subscribe::{Facility, InterestMaskSet}, Context, FlagSet, State, + subscribe::{Facility, InterestMaskSet}, }, mainloop::{ self, api::Mainloop, events::io::FlagSet as IoFlagSet, standard::IterateResult, }, - proplist::{properties, Proplist}, + proplist::{Proplist, properties}, volume::Volume, }; @@ -50,14 +50,14 @@ fn monitor( loop { match mainloop.iterate(true) { IterateResult::Quit(_) | IterateResult::Err(_) => { - return Err("pulseaudio mainloop quit while connecting".into()) + return Err("pulseaudio mainloop quit while connecting".into()); } _ => (), } match context.borrow().get_state() { State::Ready => break, State::Failed | State::Terminated => { - return Err("could not connect to pulseaudio".into()) + return Err("could not connect to pulseaudio".into()); } _ => (), } diff --git a/src/widgets/widget.rs b/src/widgets/widget.rs index 2cd0f78..3db34ef 100644 --- a/src/widgets/widget.rs +++ b/src/widgets/widget.rs @@ -88,6 +88,9 @@ mod tests { assert_eq!(e.x + e.width, 15); assert_eq!(e.y + e.height, 102); let e2 = b.expand(a); - assert_eq!((e2.x, e2.y, e2.width, e2.height), (e.x, e.y, e.width, e.height)); + assert_eq!( + (e2.x, e2.y, e2.width, e2.height), + (e.x, e.y, e.width, e.height) + ); } }