Compare commits

..

2 Commits

Author SHA1 Message Date
502f1e89a5 initial config generation to main file 2024-03-10 22:26:02 +11:00
d7c70583c0 Better code standards 2024-03-10 22:25:39 +11:00
5 changed files with 12 additions and 13 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,4 +1,3 @@
use crate::config::Monitors;
use crate::handlers::dbus_plasma_interface; use crate::handlers::dbus_plasma_interface;
use crate::Wallpapers; use crate::Wallpapers;
@ -23,7 +22,7 @@ pub fn change_wallpapers(wallpapers: &Wallpapers) {
let javascript = generate_js(wallpapers); let javascript = generate_js(wallpapers);
let resp = proxy.evaluate_script(javascript.as_ref()); let resp = proxy.evaluate_script(javascript.as_ref());
match resp { match resp {
Ok(str) => {} Ok(_str) => {}
Err(e) => println!("{}", e), Err(e) => println!("{}", e),
} }
} }

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);