rustfmt
This commit is contained in:
+14
-7
@@ -1,9 +1,9 @@
|
|||||||
use crate::cmd::Cmd;
|
use crate::cmd::Cmd;
|
||||||
use crate::widget;
|
use crate::widget;
|
||||||
use crate::widgets;
|
use crate::widgets;
|
||||||
use std::sync::mpsc::Sender;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
use std::sync::mpsc::Sender;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
@@ -56,10 +56,7 @@ pub enum Widget {
|
|||||||
impl Widget {
|
impl Widget {
|
||||||
pub fn construct(self, tx: Sender<Cmd>) -> Option<Box<dyn widget::Widget + Send>> {
|
pub fn construct(self, tx: Sender<Cmd>) -> Option<Box<dyn widget::Widget + Send>> {
|
||||||
match self {
|
match self {
|
||||||
Widget::Margin {
|
Widget::Margin { margins, widget } => match widget.construct(tx.clone()) {
|
||||||
margins,
|
|
||||||
widget,
|
|
||||||
} => match widget.construct(tx.clone()) {
|
|
||||||
Some(w) => Some(widget::Margin::new(margins, w)),
|
Some(w) => Some(widget::Margin::new(margins, w)),
|
||||||
None => None,
|
None => None,
|
||||||
},
|
},
|
||||||
@@ -93,13 +90,23 @@ impl Widget {
|
|||||||
font_size,
|
font_size,
|
||||||
sections,
|
sections,
|
||||||
} => Some(widgets::calendar::Calendar::new(font_size, sections)),
|
} => Some(widgets::calendar::Calendar::new(font_size, sections)),
|
||||||
Widget::Launcher { font_size, length, app_opener, term_opener, url_opener } => Some(widgets::launcher::Launcher::new(
|
Widget::Launcher {
|
||||||
|
font_size,
|
||||||
|
length,
|
||||||
|
app_opener,
|
||||||
|
term_opener,
|
||||||
|
url_opener,
|
||||||
|
} => Some(widgets::launcher::Launcher::new(
|
||||||
font_size,
|
font_size,
|
||||||
length,
|
length,
|
||||||
tx.clone(),
|
tx.clone(),
|
||||||
app_opener,
|
app_opener,
|
||||||
term_opener,
|
term_opener,
|
||||||
if url_opener.len() == 0 { "xdg_open ".to_string() } else { url_opener },
|
if url_opener.len() == 0 {
|
||||||
|
"xdg_open ".to_string()
|
||||||
|
} else {
|
||||||
|
url_opener
|
||||||
|
},
|
||||||
)),
|
)),
|
||||||
Widget::Battery { font_size, length } => {
|
Widget::Battery { font_size, length } => {
|
||||||
match widgets::battery::UpowerBattery::new(font_size, length, tx.clone()) {
|
match widgets::battery::UpowerBattery::new(font_size, length, tx.clone()) {
|
||||||
|
|||||||
+4
-4
@@ -1,10 +1,10 @@
|
|||||||
|
use std::default::Default;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::fs::File;
|
||||||
use std::io::{BufRead, BufReader, Read, Write};
|
use std::io::{BufRead, BufReader, Read, Write};
|
||||||
use std::os::unix::io::AsRawFd;
|
use std::os::unix::io::AsRawFd;
|
||||||
use std::os::unix::net::{UnixListener, UnixStream};
|
use std::os::unix::net::{UnixListener, UnixStream};
|
||||||
use std::sync::mpsc::channel;
|
use std::sync::mpsc::channel;
|
||||||
use std::fs::File;
|
|
||||||
use std::default::Default;
|
|
||||||
|
|
||||||
use nix::poll::{poll, PollFd, PollFlags};
|
use nix::poll::{poll, PollFd, PollFlags};
|
||||||
use os_pipe::pipe;
|
use os_pipe::pipe;
|
||||||
@@ -40,14 +40,14 @@ fn main() {
|
|||||||
Err(_) => match env::var("HOME") {
|
Err(_) => match env::var("HOME") {
|
||||||
Ok(home) => home + "/.config/wldash",
|
Ok(home) => home + "/.config/wldash",
|
||||||
Err(_) => panic!("unable to find user folder"),
|
Err(_) => panic!("unable to find user folder"),
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let config: config::Config = match File::open(config_home + "/config.json") {
|
let config: config::Config = match File::open(config_home + "/config.json") {
|
||||||
Ok(f) => {
|
Ok(f) => {
|
||||||
let reader = BufReader::new(f);
|
let reader = BufReader::new(f);
|
||||||
serde_json::from_reader(reader).unwrap()
|
serde_json::from_reader(reader).unwrap()
|
||||||
},
|
}
|
||||||
Err(_) => Default::default(),
|
Err(_) => Default::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,14 @@ pub struct Launcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Launcher {
|
impl Launcher {
|
||||||
pub fn new(font_size: f32, length: u32, listener: Sender<Cmd>, app: String, term: String, url: String) -> Box<Launcher> {
|
pub fn new(
|
||||||
|
font_size: f32,
|
||||||
|
length: u32,
|
||||||
|
listener: Sender<Cmd>,
|
||||||
|
app: String,
|
||||||
|
term: String,
|
||||||
|
url: String,
|
||||||
|
) -> Box<Launcher> {
|
||||||
Box::new(Launcher {
|
Box::new(Launcher {
|
||||||
options: load_desktop_files(),
|
options: load_desktop_files(),
|
||||||
term_opener: term,
|
term_opener: term,
|
||||||
|
|||||||
Reference in New Issue
Block a user