diff --git a/src/config.rs b/src/config.rs index 590c89e..c029a8e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,5 +1,6 @@ use core::fmt; - +use std::fs::File; +use std::io::prelude::*; use untildify; #[derive(Debug)] @@ -105,3 +106,12 @@ impl fmt::Display for Config { write!(f, "Mycelium Config: X Server: {xserv}, Wallpaper Engine: {wallpaper_engine}, Wallpaper Directories: {wallpaper_dirs}, Monitors: {monitors}", xserv = self.x_server, wallpaper_engine = self.wallpaper_engine, wallpaper_dirs = self.wallpaper_dir, monitors = self.monitors) } } + +impl Config { + pub fn load_from_file(self, file_path: String) -> String { + let mut file = File::open(file_path).unwrap(); + let mut contents = String::new(); + file.read_to_string(&mut contents).unwrap(); + contents.to_string() + } +} diff --git a/src/main.rs b/src/main.rs index 4dc7245..c1db1e9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,5 +3,8 @@ mod config; fn main() { let config = config::Config::new(); - println!("{}", config); + println!( + "{}", + config.load_from_file("/home/ben/.config/wallpaperctl/wallpaperctl.ini".to_owned()) + ); }