cargo fmt

This commit is contained in:
Kenny Levinsen
2020-01-08 11:31:56 +01:00
parent d6b53be516
commit 8877674f43
13 changed files with 80 additions and 41 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
use crate::color::Color;
use crate::widgets::bar_widget::{BarWidget, BarWidgetImpl};
use crate::widget::WaitContext;
use crate::widgets::bar_widget::{BarWidget, BarWidgetImpl};
use alsa::mixer::{Mixer, Selem, SelemChannelId, SelemId};
+1 -1
View File
@@ -1,7 +1,7 @@
use crate::cmd::Cmd;
use crate::color::Color;
use crate::widgets::bar_widget::{BarWidget, BarWidgetImpl};
use crate::widget::WaitContext;
use crate::widgets::bar_widget::{BarWidget, BarWidgetImpl};
use std::cell::RefCell;
use std::collections::HashMap;
+1 -1
View File
@@ -1,6 +1,6 @@
use crate::color::Color;
use crate::widgets::bar_widget::{BarWidget, BarWidgetImpl};
use crate::widget::WaitContext;
use crate::widgets::bar_widget::{BarWidget, BarWidgetImpl};
use std::fs::OpenOptions;
use std::io::{Error, ErrorKind};
+1 -1
View File
@@ -1,6 +1,6 @@
use crate::color::Color;
use crate::draw::{draw_bar, draw_box, Font, ROBOTO_REGULAR};
use crate::widget::{DrawContext, DrawReport, KeyState, ModifiersState, Widget, WaitContext};
use crate::widget::{DrawContext, DrawReport, KeyState, ModifiersState, WaitContext, Widget};
use std::sync::{Arc, Mutex};
+21 -13
View File
@@ -1,7 +1,7 @@
use crate::cmd::Cmd;
use crate::color::Color;
use crate::widgets::bar_widget::{BarWidget, BarWidgetImpl};
use crate::widget::WaitContext;
use crate::widgets::bar_widget::{BarWidget, BarWidgetImpl};
use std::sync::mpsc::Sender;
use std::sync::{Arc, Mutex};
@@ -44,7 +44,7 @@ struct DbusConnection(dbus::Connection);
impl std::convert::AsRef<dbus::Connection> for DbusConnection {
fn as_ref(&self) -> &dbus::Connection {
return &self.0
return &self.0;
}
}
@@ -70,12 +70,14 @@ enum UpowerBatteryState {
}
impl UpowerBattery {
pub fn from_device(dirty: Arc<Mutex<bool>>, sender: Sender<Cmd>, device: &str) -> Result<Self, ::std::io::Error> {
let con = dbus::Connection::get_private(dbus::BusType::System)
.map_err(|_| ::std::io::Error::new(
::std::io::ErrorKind::Other,
"unable to open dbus",
))?;
pub fn from_device(
dirty: Arc<Mutex<bool>>,
sender: Sender<Cmd>,
device: &str,
) -> Result<Self, ::std::io::Error> {
let con = dbus::Connection::get_private(dbus::BusType::System).map_err(|_| {
::std::io::Error::new(::std::io::ErrorKind::Other, "unable to open dbus")
})?;
let device_path = format!("/org/freedesktop/UPower/devices/battery_{}", device);
let rule = format!(
@@ -85,11 +87,12 @@ impl UpowerBattery {
member='PropertiesChanged'",
&device_path
);
con.add_match(&rule)
.map_err(|_| ::std::io::Error::new(
con.add_match(&rule).map_err(|_| {
::std::io::Error::new(
::std::io::ErrorKind::Other,
"unable to add match rule to dbus connection",
))?;
)
})?;
let upower_type: dbus::arg::Variant<u32> =
match get_upower_property(&con, &device_path, "Type")?.get1() {
Some(v) => v,
@@ -173,7 +176,11 @@ impl UpowerBattery {
impl BarWidgetImpl for UpowerBattery {
fn wait(&mut self, ctx: &mut WaitContext) {
for _ in self.con.as_ref().watch_handle(self.watch.fd(), dbus::WatchEvent::Readable as u32) {
for _ in self
.con
.as_ref()
.watch_handle(self.watch.fd(), dbus::WatchEvent::Readable as u32)
{
let capacity = get_upower_property(self.con.as_ref(), &self.device_path, "Percentage")
.unwrap()
.get1::<dbus::arg::Variant<f64>>()
@@ -199,7 +206,8 @@ impl BarWidgetImpl for UpowerBattery {
self.sender.send(Cmd::Draw).unwrap();
}
ctx.fds.push(PollFd::new(self.watch.fd(), PollFlags::POLLIN));
ctx.fds
.push(PollFd::new(self.watch.fd(), PollFlags::POLLIN));
}
fn name(&self) -> &str {
"battery"
+1 -1
View File
@@ -1,7 +1,7 @@
use crate::buffer::Buffer;
use crate::color::Color;
use crate::draw::{Font, DEJAVUSANS_MONO, ROBOTO_REGULAR};
use crate::widget::{DrawContext, DrawReport, KeyState, ModifiersState, Widget, WaitContext};
use crate::widget::{DrawContext, DrawReport, KeyState, ModifiersState, WaitContext, Widget};
use chrono::{Date, Datelike, Local};
+1 -1
View File
@@ -1,6 +1,6 @@
use crate::color::Color;
use crate::draw::{Font, ROBOTO_REGULAR};
use crate::widget::{DrawContext, DrawReport, KeyState, ModifiersState, Widget, WaitContext};
use crate::widget::{DrawContext, DrawReport, KeyState, ModifiersState, WaitContext, Widget};
use chrono::{DateTime, Datelike, Duration, Local, Timelike};
+1 -1
View File
@@ -1,6 +1,6 @@
use crate::color::Color;
use crate::draw::{Font, ROBOTO_REGULAR};
use crate::widget::{DrawContext, DrawReport, KeyState, ModifiersState, Widget, WaitContext};
use crate::widget::{DrawContext, DrawReport, KeyState, ModifiersState, WaitContext, Widget};
use chrono::{DateTime, Datelike, Local};
+9 -7
View File
@@ -3,13 +3,13 @@ use crate::cmd::Cmd;
use crate::color::Color;
use crate::desktop::{load_desktop_files, Desktop};
use crate::draw::{Font, ROBOTO_REGULAR};
use crate::widget::{DrawContext, DrawReport, KeyState, ModifiersState, Widget, WaitContext};
use crate::widget::{DrawContext, DrawReport, KeyState, ModifiersState, WaitContext, Widget};
use std::cell::RefCell;
use std::cmp::Ordering;
use std::collections::HashMap;
use std::process::Command;
use std::sync::mpsc::Sender;
use std::collections::HashMap;
use fuzzy_matcher::skim::{fuzzy_indices, fuzzy_match};
use smithay_client_toolkit::keyboard::keysyms;
@@ -82,7 +82,7 @@ impl Launcher {
let size = if idx == self.offset && self.input.len() > 0 {
let (_, indices) =
fuzzy_indices(&m.name.to_lowercase(), &self.input.to_lowercase())
.unwrap_or((0, vec![]));
.unwrap_or((0, vec![]));
let mut colors = Vec::with_capacity(m.name.len());
for pos in 0..m.name.len() {
if indices.contains(&pos) {
@@ -211,7 +211,7 @@ impl Matcher {
// Skip over new matches for the same program that are worse
// than the one we already have.
if ma_old > &ma {
return
return;
}
}
@@ -220,9 +220,11 @@ impl Matcher {
}
fn matches(&self) -> Vec<Desktop> {
let mut m = self.matches.iter()
.map(|(key, ma)| (ma.clone(), key.clone()))
.collect::<Vec<(i64, Desktop)>>();
let mut m = self
.matches
.iter()
.map(|(key, ma)| (ma.clone(), key.clone()))
.collect::<Vec<(i64, Desktop)>>();
m.sort_by(|(ma1, d1), (ma2, d2)| {
if ma1 > ma2 {