cargo fmt

Pure formatting, no functional change.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Bendik Aagaard Lynghaug
2026-10-03 09:16:15 +00:00
co-authored by Claude Fable 5.1
parent 856f8d8bf4
commit 42ffe9c492
14 changed files with 52 additions and 47 deletions
+1 -1
View File
@@ -19,8 +19,8 @@ use nix::{
use memmap2::MmapMut; use memmap2::MmapMut;
use wayland_client::{ use wayland_client::{
protocol::{wl_buffer, wl_shm, wl_shm_pool},
Dispatch, QueueHandle, Dispatch, QueueHandle,
protocol::{wl_buffer, wl_shm, wl_shm_pool},
}; };
use crate::color::Color; use crate::color::Color;
+1 -1
View File
@@ -6,7 +6,7 @@ use std::sync::{Arc, Mutex};
use crate::{ use crate::{
event::Events, event::Events,
fonts::{find_font, FontMap}, fonts::{FontMap, find_font},
widgets::{ widgets::{
Backlight, Battery, Calendar, Clock, Date, HorizontalLayout, IndexedLayout, Interface, Backlight, Battery, Calendar, Clock, Date, HorizontalLayout, IndexedLayout, Interface,
InvertedHorizontalLayout, InvertedVerticalLayout, Layout, Line, Margin, PulseAudio, InvertedHorizontalLayout, InvertedVerticalLayout, Layout, Line, Margin, PulseAudio,
+6 -6
View File
@@ -1,7 +1,7 @@
use crate::buffer::BufferView; use crate::buffer::BufferView;
use crate::{color::Color, fonts::FontRef}; use crate::{color::Color, fonts::FontRef};
use rusttype::{point, Scale}; use rusttype::{Scale, point};
use std::collections::HashMap; use std::collections::HashMap;
struct CachedGlyph { struct CachedGlyph {
@@ -121,7 +121,7 @@ impl<'a> Font<'a> {
return Err(::std::io::Error::new( return Err(::std::io::Error::new(
::std::io::ErrorKind::Other, ::std::io::ErrorKind::Other,
format!("glyph for {:} not in cache", ch), format!("glyph for {:} not in cache", ch),
)) ));
} }
}; };
glyphs.push(glyph); glyphs.push(glyph);
@@ -154,7 +154,7 @@ impl<'a> Font<'a> {
return Err(::std::io::Error::new( return Err(::std::io::Error::new(
::std::io::ErrorKind::Other, ::std::io::ErrorKind::Other,
format!("glyph for {:} not in cache", ch), format!("glyph for {:} not in cache", ch),
)) ));
} }
}; };
glyphs.push(glyph); glyphs.push(glyph);
@@ -206,7 +206,7 @@ impl<'a> Font<'a> {
return Err(::std::io::Error::new( return Err(::std::io::Error::new(
::std::io::ErrorKind::Other, ::std::io::ErrorKind::Other,
format!("glyph for {:} not in cache", ch), format!("glyph for {:} not in cache", ch),
)) ));
} }
}; };
let width = glyph.advance; let width = glyph.advance;
@@ -255,7 +255,7 @@ impl<'a> Font<'a> {
return Err(::std::io::Error::new( return Err(::std::io::Error::new(
::std::io::ErrorKind::Other, ::std::io::ErrorKind::Other,
format!("glyph for {:} not in cache", ch), format!("glyph for {:} not in cache", ch),
)) ));
} }
}; };
glyphs.push(glyph); glyphs.push(glyph);
@@ -287,7 +287,7 @@ impl<'a> Font<'a> {
return Err(::std::io::Error::new( return Err(::std::io::Error::new(
::std::io::ErrorKind::Other, ::std::io::ErrorKind::Other,
format!("glyph for {:} not in cache", ch), format!("glyph for {:} not in cache", ch),
)) ));
} }
}; };
glyphs.push(glyph); glyphs.push(glyph);
+2 -5
View File
@@ -12,12 +12,9 @@
//! calloop event loop. Not doing so will prevent key repetition to work //! calloop event loop. Not doing so will prevent key repetition to work
//! (but the rest of the functionnality will not be affected). //! (but the rest of the functionnality will not be affected).
use std::{ use std::{default::Default, os::unix::io::OwnedFd};
default::Default,
os::unix::io::OwnedFd,
};
use wayland_client::{protocol::wl_keyboard, WEnum}; use wayland_client::{WEnum, protocol::wl_keyboard};
use xkbcommon::xkb; use xkbcommon::xkb;
pub use xkbcommon::xkb::keysyms; pub use xkbcommon::xkb::keysyms;
+5 -3
View File
@@ -1,11 +1,11 @@
use std::time::Duration; use std::time::Duration;
use calloop::{ use calloop::{
EventSource, Poll, PostAction, Readiness, Token, TokenFactory,
channel::{self, Channel}, channel::{self, Channel},
timer::{TimeoutAction, Timer}, 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; use super::KeyEvent;
@@ -136,7 +136,9 @@ impl EventSource for KeyRepeatSource {
let mut next_deadline = deadline; let mut next_deadline = deadline;
if now - deadline > *rate * 2 { if now - deadline > *rate * 2 {
// We're way behind, let's just set a new time // 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; next_deadline = now + *rate;
} else { } else {
while next_deadline < now { while next_deadline < now {
+3 -4
View File
@@ -12,8 +12,8 @@ mod widgets;
use wayland_client::{Connection, QueueHandle, WaylandSource}; use wayland_client::{Connection, QueueHandle, WaylandSource};
use calloop::{ use calloop::{
timer::{TimeoutAction, Timer},
EventLoop, EventLoop,
timer::{TimeoutAction, Timer},
}; };
use chrono::{Duration, Local, Timelike}; use chrono::{Duration, Local, Timelike};
@@ -30,12 +30,11 @@ use utils::{
use widgets::{Geometry, Widget}; use widgets::{Geometry, Widget};
use std::{ use std::{
env, env, fs,
fs::File, fs::File,
fs,
path::Path,
io::{BufRead, BufReader, Write}, io::{BufRead, BufReader, Write},
os::unix::net::{UnixListener, UnixStream}, os::unix::net::{UnixListener, UnixStream},
path::Path,
rc::Rc, rc::Rc,
thread, thread,
}; };
+4 -2
View File
@@ -7,11 +7,11 @@ use std::{
}; };
use wayland_client::{ use wayland_client::{
Connection, Dispatch, QueueHandle, WEnum,
protocol::{ protocol::{
wl_buffer, wl_callback, wl_compositor, wl_keyboard, wl_pointer, wl_registry, wl_seat, 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, wl_shm, wl_shm_pool, wl_subcompositor, wl_subsurface, wl_surface,
}, },
Connection, Dispatch, QueueHandle, WEnum,
}; };
use wayland_protocols::{ use wayland_protocols::{
@@ -141,7 +141,9 @@ impl State {
activation.activate(key, surface); activation.activate(key, surface);
let activation_token = activation.get_activation_token(qh, ()); let activation_token = activation.get_activation_token(qh, ());
activation_token.commit(); activation_token.commit();
unsafe { env::remove_var("XDG_ACTIVATION_TOKEN"); } unsafe {
env::remove_var("XDG_ACTIVATION_TOKEN");
}
} }
_ => (), _ => (),
} }
+5 -2
View File
@@ -2,7 +2,7 @@ use std::{
cmp::Ordering, cmp::Ordering,
collections::HashSet, collections::HashSet,
error::Error, error::Error,
fs::{read_to_string, File}, fs::{File, read_to_string},
hash::{Hash, Hasher}, hash::{Hash, Hasher},
io::{Error as io_error, ErrorKind}, io::{Error as io_error, ErrorKind},
path::Path, path::Path,
@@ -104,7 +104,10 @@ pub fn load_desktop_files() -> Vec<Desktop> {
let mut seen: HashSet<String> = HashSet::new(); let mut seen: HashSet<String> = HashSet::new();
for dir in dirs { 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. // Entries are often symlinks, so only rule out directories.
if entry.file_type().is_dir() if entry.file_type().is_dir()
|| entry.path().extension().and_then(|e| e.to_str()) != Some("desktop") || entry.path().extension().and_then(|e| e.to_str()) != Some("desktop")
+5 -2
View File
@@ -6,8 +6,8 @@ use std::{
}; };
use dbus::blocking::{ use dbus::blocking::{
stdintf::org_freedesktop_dbus::{Properties, PropertiesPropertiesChanged},
LocalConnection, LocalConnection,
stdintf::org_freedesktop_dbus::{Properties, PropertiesPropertiesChanged},
}; };
use crate::{ use crate::{
@@ -64,7 +64,10 @@ fn battery_present() -> Result<bool, Box<dyn Error>> {
Ok(present) Ok(present)
} }
fn monitor(inner: Arc<Mutex<InnerBattery>>, events: Arc<Mutex<Events>>) -> Result<(), Box<dyn Error>> { fn monitor(
inner: Arc<Mutex<InnerBattery>>,
events: Arc<Mutex<Events>>,
) -> Result<(), Box<dyn Error>> {
let conn = LocalConnection::new_system()?; let conn = LocalConnection::new_system()?;
let proxy = conn.with_proxy( let proxy = conn.with_proxy(
"org.freedesktop.UPower", "org.freedesktop.UPower",
+2 -2
View File
@@ -323,7 +323,7 @@ impl<'a> Widget for Calendar {
y: 0, y: 0,
width: 0, width: 0,
height: 0, height: 0,
} };
} }
x => x, x => x,
}; };
@@ -335,7 +335,7 @@ impl<'a> Widget for Calendar {
y: 0, y: 0,
width: 0, width: 0,
height: 0, height: 0,
} };
} }
y => y, y => y,
}; };
+9 -13
View File
@@ -1,10 +1,10 @@
use std::{ use std::{
cmp::{max, min, Ordering}, cmp::{Ordering, max, min},
collections::HashMap, collections::HashMap,
default::Default, default::Default,
fs::{read_to_string, File}, fs::{File, read_to_string},
io::Write, io::Write,
process::{exit, Command}, process::{Command, exit},
sync::{Arc, Mutex}, sync::{Arc, Mutex},
thread, thread,
}; };
@@ -14,18 +14,18 @@ use crate::{
color::Color, color::Color,
event::{Event, Events, PointerButton, PointerEvent}, event::{Event, Events, PointerButton, PointerEvent},
fonts::FontMap, fonts::FontMap,
keyboard::{keysyms, KeyEvent}, keyboard::{KeyEvent, keysyms},
utils::{ utils::{
desktop::{load_desktop_cache, load_desktop_files, write_desktop_cache, Desktop}, desktop::{Desktop, load_desktop_cache, load_desktop_files, write_desktop_cache},
xdg, xdg,
}, },
widgets::{Geometry, Widget}, widgets::{Geometry, Widget},
}; };
use fuzzy_matcher::skim::SkimMatcherV2;
use fuzzy_matcher::FuzzyMatcher; use fuzzy_matcher::FuzzyMatcher;
use fuzzy_matcher::skim::SkimMatcherV2;
use unicode_segmentation::UnicodeSegmentation; use unicode_segmentation::UnicodeSegmentation;
use wayland_client::{protocol::wl_keyboard, WEnum}; use wayland_client::{WEnum, protocol::wl_keyboard};
struct Matcher { struct Matcher {
matches: HashMap<Desktop, i64>, matches: HashMap<Desktop, i64>,
@@ -692,11 +692,7 @@ impl Interface {
if line_height == 0 { if line_height == 0 {
return; return;
} }
let height = self let height = self.inner.geometry.height.saturating_sub(line_height + 8);
.inner
.geometry
.height
.saturating_sub(line_height + 8);
let lines = height / line_height; let lines = height / line_height;
let offset = height % line_height; let offset = height % line_height;
@@ -847,7 +843,7 @@ impl Widget for Interface {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::{strip_field_codes, Prompt, PromptMode}; use super::{Prompt, PromptMode, strip_field_codes};
#[test] #[test]
fn prompt_cursor_is_grapheme_based() { fn prompt_cursor_is_grapheme_based() {
+1 -1
View File
@@ -113,7 +113,7 @@ impl Layout for VerticalLayout {
pub trait WidgetUpdater { pub trait WidgetUpdater {
fn geometry_update(&mut self, idx: usize, fonts: &mut FontMap, geometry: &Geometry) 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; fn minimum_size(&mut self, idx: usize, fonts: &mut FontMap) -> Geometry;
} }
+4 -4
View File
@@ -26,13 +26,13 @@ fn monitor(
use libpulse_binding::{ use libpulse_binding::{
callbacks::ListResult, callbacks::ListResult,
context::{ context::{
subscribe::{Facility, InterestMaskSet},
Context, FlagSet, State, Context, FlagSet, State,
subscribe::{Facility, InterestMaskSet},
}, },
mainloop::{ mainloop::{
self, api::Mainloop, events::io::FlagSet as IoFlagSet, standard::IterateResult, self, api::Mainloop, events::io::FlagSet as IoFlagSet, standard::IterateResult,
}, },
proplist::{properties, Proplist}, proplist::{Proplist, properties},
volume::Volume, volume::Volume,
}; };
@@ -50,14 +50,14 @@ fn monitor(
loop { loop {
match mainloop.iterate(true) { match mainloop.iterate(true) {
IterateResult::Quit(_) | IterateResult::Err(_) => { 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() { match context.borrow().get_state() {
State::Ready => break, State::Ready => break,
State::Failed | State::Terminated => { State::Failed | State::Terminated => {
return Err("could not connect to pulseaudio".into()) return Err("could not connect to pulseaudio".into());
} }
_ => (), _ => (),
} }
+4 -1
View File
@@ -88,6 +88,9 @@ mod tests {
assert_eq!(e.x + e.width, 15); assert_eq!(e.x + e.width, 15);
assert_eq!(e.y + e.height, 102); assert_eq!(e.y + e.height, 102);
let e2 = b.expand(a); 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)
);
} }
} }