initial config generation to main file

This commit is contained in:
Benjamyn Love 2024-03-10 22:26:02 +11:00
parent d7c70583c0
commit 502f1e89a5
4 changed files with 11 additions and 11 deletions

View File

@ -4,7 +4,7 @@ use core::fmt;
use crate::enums::*; use crate::enums::*;
use untildify; use untildify;
#[derive(Debug)] #[derive(Debug, Clone)]
pub struct Monitors { pub struct Monitors {
pub monitors: Vec<MonitorType>, pub monitors: Vec<MonitorType>,
} }
@ -29,7 +29,7 @@ impl fmt::Display for Monitors {
} }
} }
#[derive(Debug)] #[derive(Debug, Clone)]
pub struct WallpaperDir { pub struct WallpaperDir {
ultrawide: String, ultrawide: String,
horizontal: String, horizontal: String,
@ -68,7 +68,7 @@ impl fmt::Display for WallpaperDir {
} }
} }
#[derive(Debug)] #[derive(Debug, Clone)]
pub struct Config { pub struct Config {
pub x_server: String, pub x_server: String,
pub wallpaper_engine: WallpaperHandler, pub wallpaper_engine: WallpaperHandler,

View File

@ -1,6 +1,6 @@
use core::fmt; use core::fmt;
#[derive(Debug)] #[derive(Debug, Clone)]
pub enum WallpaperHandler { pub enum WallpaperHandler {
Feh, Feh,
Plasma, Plasma,

View File

@ -6,7 +6,7 @@ use std::fmt::Write as _;
use crate::config::*; use crate::config::*;
use crate::enums::*; use crate::enums::*;
#[derive(Debug)] #[derive(Debug, Clone)]
pub struct Wallpaper { pub struct Wallpaper {
path: String, path: String,
} }
@ -23,7 +23,7 @@ impl fmt::Display for Wallpaper {
} }
} }
#[derive(Debug)] #[derive(Debug, Clone)]
pub struct Wallpapers { pub struct Wallpapers {
ultrawide: Vec<Wallpaper>, ultrawide: Vec<Wallpaper>,
horizontal: Vec<Wallpaper>, horizontal: Vec<Wallpaper>,
@ -32,14 +32,12 @@ pub struct Wallpapers {
} }
impl Wallpapers { impl Wallpapers {
pub fn new() -> Wallpapers { pub fn new(config: Config) -> Wallpapers {
Wallpapers { Wallpapers {
ultrawide: vec![], ultrawide: vec![],
horizontal: vec![], horizontal: vec![],
vertical: vec![], vertical: vec![],
config: Config::from_config( config,
"/home/ben/.config/wallpaperctl/wallpaperctl.ini".to_owned(),
),
} }
} }

View File

@ -1,11 +1,13 @@
mod config; mod config;
use config::*;
mod enums; mod enums;
mod files; mod files;
use files::*; use files::*;
mod handlers; mod handlers;
fn main() { fn main() {
let mut wallpapers = Wallpapers::new(); let config = Config::from_config("/home/ben/.config/wallpaperctl/wallpaperctl.ini".to_owned());
let mut wallpapers = Wallpapers::new(config.clone());
wallpapers.load_all(); wallpapers.load_all();
handlers::plasma::change_wallpapers(&wallpapers); handlers::plasma::change_wallpapers(&wallpapers);