cargo fmt
This commit is contained in:
+5
-1
@@ -123,7 +123,11 @@ impl Widget {
|
||||
Err(_) => None,
|
||||
}
|
||||
}
|
||||
Widget::Backlight { device, font_size, length } => {
|
||||
Widget::Backlight {
|
||||
device,
|
||||
font_size,
|
||||
length,
|
||||
} => {
|
||||
let d = if device == "" {
|
||||
"intel_backlight"
|
||||
} else {
|
||||
|
||||
+9
-3
@@ -37,9 +37,15 @@ impl Desktop {
|
||||
hidden: desktop.get("Hidden").unwrap_or(&"".to_string()) == "true",
|
||||
exec: desktop.get("Exec").map(|x| x.to_string()),
|
||||
url: desktop.get("URL").map(|x| x.to_string()),
|
||||
keywords: desktop.get("Keywords").map(|x|
|
||||
x.split(";").map(|y| y.trim().to_string()).filter(|z| z != "").collect()
|
||||
).unwrap_or(vec![]),
|
||||
keywords: desktop
|
||||
.get("Keywords")
|
||||
.map(|x| {
|
||||
x.split(";")
|
||||
.map(|y| y.trim().to_string())
|
||||
.filter(|z| z != "")
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or(vec![]),
|
||||
}),
|
||||
None => Err(Box::new(io_error::new(
|
||||
ErrorKind::NotFound,
|
||||
|
||||
+28
-9
@@ -5,10 +5,10 @@ use std::os::unix::io::AsRawFd;
|
||||
use std::os::unix::net::{UnixListener, UnixStream};
|
||||
use std::sync::mpsc::channel;
|
||||
|
||||
use timerfd::{TimerFd, TimerState, SetTimeFlags};
|
||||
use chrono::{Duration, Local};
|
||||
use nix::poll::{poll, PollFd, PollFlags};
|
||||
use os_pipe::pipe;
|
||||
use chrono::{Local, Duration};
|
||||
use timerfd::{SetTimeFlags, TimerFd, TimerState};
|
||||
|
||||
mod app;
|
||||
mod buffer;
|
||||
@@ -198,7 +198,7 @@ fn main() {
|
||||
app.cmd_queue().lock().unwrap().push_back(Cmd::Draw);
|
||||
|
||||
let mut visible = !daemon;
|
||||
let mut wait_ctx = WaitContext{
|
||||
let mut wait_ctx = WaitContext {
|
||||
fds: Vec::new(),
|
||||
target_time: None,
|
||||
};
|
||||
@@ -275,13 +275,20 @@ fn main() {
|
||||
} else {
|
||||
Duration::seconds(0)
|
||||
};
|
||||
timer.set_state(TimerState::Oneshot(sleep.to_std().unwrap()), SetTimeFlags::Default);
|
||||
timer.set_state(
|
||||
TimerState::Oneshot(sleep.to_std().unwrap()),
|
||||
SetTimeFlags::Default,
|
||||
);
|
||||
wait_ctx.fds.push(tm_fd);
|
||||
}
|
||||
|
||||
poll(&mut wait_ctx.fds, -1).unwrap();
|
||||
|
||||
if wait_ctx.fds[0].revents().unwrap().contains(PollFlags::POLLIN) {
|
||||
if wait_ctx.fds[0]
|
||||
.revents()
|
||||
.unwrap()
|
||||
.contains(PollFlags::POLLIN)
|
||||
{
|
||||
if let Some(guard) = app.event_queue().prepare_read() {
|
||||
if let Err(e) = guard.read_events() {
|
||||
if e.kind() != ::std::io::ErrorKind::WouldBlock {
|
||||
@@ -298,12 +305,20 @@ fn main() {
|
||||
.expect("Failed to dispatch all messages.");
|
||||
}
|
||||
|
||||
if wait_ctx.fds[1].revents().unwrap().contains(PollFlags::POLLIN) {
|
||||
if wait_ctx.fds[1]
|
||||
.revents()
|
||||
.unwrap()
|
||||
.contains(PollFlags::POLLIN)
|
||||
{
|
||||
let mut v = [0x00];
|
||||
rx_pipe.read_exact(&mut v).unwrap();
|
||||
}
|
||||
|
||||
if wait_ctx.fds[2].revents().unwrap().contains(PollFlags::POLLIN) {
|
||||
if wait_ctx.fds[2]
|
||||
.revents()
|
||||
.unwrap()
|
||||
.contains(PollFlags::POLLIN)
|
||||
{
|
||||
if let Ok((stream, _)) = listener.accept() {
|
||||
let client_queue = q.clone();
|
||||
let mut client_pipe = ipc_pipe.try_clone().unwrap();
|
||||
@@ -331,8 +346,12 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
if wait_ctx.target_time.is_some() &&
|
||||
wait_ctx.fds[wait_ctx.fds.len()-1].revents().unwrap().contains(PollFlags::POLLIN) {
|
||||
if wait_ctx.target_time.is_some()
|
||||
&& wait_ctx.fds[wait_ctx.fds.len() - 1]
|
||||
.revents()
|
||||
.unwrap()
|
||||
.contains(PollFlags::POLLIN)
|
||||
{
|
||||
timer.read();
|
||||
q.lock().unwrap().push_back(Cmd::Draw);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
use nix::poll::{PollFd};
|
||||
use crate::buffer::Buffer;
|
||||
use crate::color::Color;
|
||||
use chrono::{DateTime, Local};
|
||||
use nix::poll::PollFd;
|
||||
pub use smithay_client_toolkit::keyboard::{KeyState, ModifiersState};
|
||||
|
||||
pub struct DrawContext<'a> {
|
||||
|
||||
@@ -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,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,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,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
@@ -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,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,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
@@ -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};
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user