From 99c3480323f2df0c1cd455e2e03e832c1196050a Mon Sep 17 00:00:00 2001 From: Andreas Grois Date: Wed, 7 Apr 2021 21:29:02 +0200 Subject: First semi-working implementation. --- src/config.rs | 45 --------------------------------------------- src/main.rs | 6 ------ src/module_communication.rs | 18 ------------------ 3 files changed, 69 deletions(-) delete mode 100644 src/config.rs delete mode 100644 src/main.rs delete mode 100644 src/module_communication.rs (limited to 'src') diff --git a/src/config.rs b/src/config.rs deleted file mode 100644 index 2c44978..0000000 --- a/src/config.rs +++ /dev/null @@ -1,45 +0,0 @@ -use serde::{Serialize, Deserialize}; - -#[derive(Serialize, Deserialize, Debug)] -pub struct SwaystatusConfig { - separator : Option, //Separator character between elements. - plugin_path : Option, //path to load plugins from. If unset, hardcoded value is used. - elements : Option>, //plugins to display and their config section. -} - -fn create_default_config() -> SwaystatusConfig { - return SwaystatusConfig{ - separator : Some(String::from(", ")), - plugin_path : Some(String::from("")), - //elements : Some(Vec::new())}; - elements : Some(vec!((String::from("time"), String::from("format = \"yyyy-mm-dd hh-mm-ss\"")))) - }; -} - -pub enum SwaystatusConfigErrors -{ - FileNotFound, - ParsingError { - message : String - } -} - -pub fn print_sample_config() { - let default_config = create_default_config(); - let output = toml::to_string(&default_config).unwrap(); - print!("{}", output); -} - -pub fn read_config(path : &std::path::Path) -> Result { - let config_file = match std::fs::read_to_string(path) { - Ok(x) => x, - Err (_) => return Err(SwaystatusConfigErrors::FileNotFound) - }; - let result = match toml::from_str(&config_file) { - Ok(x) => x, - Err(e) => return Err(SwaystatusConfigErrors::ParsingError{message: e.to_string()}) - }; - - return Ok(result); - -} diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index c85aaa1..0000000 --- a/src/main.rs +++ /dev/null @@ -1,6 +0,0 @@ -mod module_communication; -mod config; - -fn main() { - config::print_sample_config(); -} diff --git a/src/module_communication.rs b/src/module_communication.rs deleted file mode 100644 index 3d4aefe..0000000 --- a/src/module_communication.rs +++ /dev/null @@ -1,18 +0,0 @@ -pub enum MsgMainToModule { - Quit, -} -pub enum MsgModuleToMain { - UpdateText { - text : Result - } -} - -pub trait SwayStatusModule { - fn new(from_main : crossbeam_channel::Receiver, - to_main : crossbeam_channel::Sender, - module_settings : &str) -> Result,String>; - - fn get_name(&self) -> &'static str; - - fn run(&self); -} -- cgit v1.2.3