Implemented main script logic

This commit is contained in:
Benjamyn Love 2024-03-10 22:35:32 +11:00
parent 502f1e89a5
commit 5a2fb02d9b
4 changed files with 37 additions and 1 deletions

5
src/handlers/feh.rs Normal file
View File

@ -0,0 +1,5 @@
use crate::Wallpapers;
pub fn change_wallpapers(wallpapers: &Wallpapers) {
println!("Not implemented");
}

5
src/handlers/gnome.rs Normal file
View File

@ -0,0 +1,5 @@
use crate::Wallpapers;
pub fn change_wallpapers(wallpapers: &Wallpapers) {
println!("Not implemented");
}

View File

@ -2,3 +2,7 @@ pub mod dbus_plasma_interface;
use dbus_plasma_interface::*; use dbus_plasma_interface::*;
pub mod plasma; pub mod plasma;
use plasma::*; use plasma::*;
pub mod feh;
use feh::*;
pub mod gnome;
use gnome::*;

View File

@ -2,13 +2,35 @@ mod config;
use config::*; use config::*;
mod enums; mod enums;
mod files; mod files;
use enums::WallpaperHandler;
use files::*; use files::*;
mod handlers; mod handlers;
fn main() { fn main() {
// Load the config file from the default path
// TODO: Have this load from the users home directory
let config = Config::from_config("/home/ben/.config/wallpaperctl/wallpaperctl.ini".to_owned()); let config = Config::from_config("/home/ben/.config/wallpaperctl/wallpaperctl.ini".to_owned());
// Initialise the `Wallpapers` struct with a clone of the config
let mut wallpapers = Wallpapers::new(config.clone()); let mut wallpapers = Wallpapers::new(config.clone());
// Load all wallpapers based on the config file specs
wallpapers.load_all(); wallpapers.load_all();
handlers::plasma::change_wallpapers(&wallpapers);
// Check the configured Wallpaper engine and run the change_wallpapers() method from the respective handlers
let wallpaper_engine = config.wallpaper_engine;
match wallpaper_engine {
WallpaperHandler::Plasma => {
handlers::plasma::change_wallpapers(&wallpapers);
}
WallpaperHandler::Feh => {
handlers::feh::change_wallpapers(&wallpapers);
}
WallpaperHandler::Gnome => {
handlers::gnome::change_wallpapers(&wallpapers);
}
_ => {
println!("Error: Unknown wallpaper engine");
}
}
} }