Code cleanup
This commit is contained in:
parent
df7368d458
commit
ba5a48dae1
@ -10,9 +10,10 @@ Whats needed to get feature parity
|
|||||||
- Support for [ultrawide, horizontal, vertical] displays [✓]
|
- Support for [ultrawide, horizontal, vertical] displays [✓]
|
||||||
|
|
||||||
What still needs to be done
|
What still needs to be done
|
||||||
- Code cleanup []
|
- Code cleanup [✓]
|
||||||
- Handler for feh [✓]
|
- Handler for feh [✓]
|
||||||
|
|
||||||
|
I think this is now in feature parity of the python script
|
||||||
|
|
||||||
What I want to add
|
What I want to add
|
||||||
- Wallhaven API support
|
- Wallhaven API support
|
||||||
|
|||||||
@ -10,10 +10,6 @@ pub struct Monitors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Monitors {
|
impl Monitors {
|
||||||
pub fn new() -> Monitors {
|
|
||||||
Monitors { monitors: vec![] }
|
|
||||||
}
|
|
||||||
|
|
||||||
fn add(&mut self, mon_type: MonitorType) {
|
fn add(&mut self, mon_type: MonitorType) {
|
||||||
self.monitors.push(mon_type);
|
self.monitors.push(mon_type);
|
||||||
}
|
}
|
||||||
@ -37,15 +33,6 @@ pub struct WallpaperDir {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl WallpaperDir {
|
impl WallpaperDir {
|
||||||
pub fn new() -> WallpaperDir {
|
|
||||||
let expanded_tilde: String = untildify::untildify("~/");
|
|
||||||
WallpaperDir {
|
|
||||||
ultrawide: expanded_tilde.clone(),
|
|
||||||
horizontal: expanded_tilde.clone(),
|
|
||||||
vertical: expanded_tilde.clone(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get(&self, monitor_type: MonitorType) -> String {
|
pub fn get(&self, monitor_type: MonitorType) -> String {
|
||||||
match monitor_type {
|
match monitor_type {
|
||||||
MonitorType::Ultrawide => self.ultrawide.to_string(),
|
MonitorType::Ultrawide => self.ultrawide.to_string(),
|
||||||
@ -77,15 +64,6 @@ pub struct Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
pub fn new() -> Config {
|
|
||||||
Config {
|
|
||||||
x_server: String::new(),
|
|
||||||
wallpaper_engine: WallpaperHandler::Plasma,
|
|
||||||
wallpaper_dir: WallpaperDir::new(),
|
|
||||||
monitors: Monitors::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn from_config(file_path: String) -> Config {
|
pub fn from_config(file_path: String) -> Config {
|
||||||
let mut config = Ini::new();
|
let mut config = Ini::new();
|
||||||
let map = config.load(file_path).unwrap();
|
let map = config.load(file_path).unwrap();
|
||||||
|
|||||||
19
src/enums.rs
19
src/enums.rs
@ -49,22 +49,3 @@ impl fmt::Display for MonitorType {
|
|||||||
write!(f, "{:?}", self)
|
write!(f, "{:?}", self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum ImageTypes {
|
|
||||||
PNG,
|
|
||||||
JPG,
|
|
||||||
JPEG,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ImageTypes {
|
|
||||||
pub fn get_types() -> Vec<String> {
|
|
||||||
vec!["png".to_string(), "jpg".to_string(), "jpeg".to_string()]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for ImageTypes {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
write!(f, "{:?}", self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -11,12 +11,6 @@ pub struct Wallpaper {
|
|||||||
path: String,
|
path: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Wallpaper {
|
|
||||||
pub fn new(path: String) -> Wallpaper {
|
|
||||||
Wallpaper { path }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for Wallpaper {
|
impl fmt::Display for Wallpaper {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "{}", self.path)
|
write!(f, "{}", self.path)
|
||||||
@ -56,7 +50,8 @@ impl Wallpapers {
|
|||||||
.wallpaper_dir
|
.wallpaper_dir
|
||||||
.get(monitor_type.clone())
|
.get(monitor_type.clone())
|
||||||
.to_owned();
|
.to_owned();
|
||||||
for filetype in ImageTypes::get_types().iter() {
|
let types = vec!["png".to_string(), "jpg".to_string(), "jpeg".to_string()];
|
||||||
|
for filetype in types.iter() {
|
||||||
let mut tmp_path = path.clone();
|
let mut tmp_path = path.clone();
|
||||||
let mut tmp_glob = String::new();
|
let mut tmp_glob = String::new();
|
||||||
write!(&mut tmp_glob, "/**/*.{}", filetype).unwrap();
|
write!(&mut tmp_glob, "/**/*.{}", filetype).unwrap();
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use crate::Wallpapers;
|
use crate::Wallpapers;
|
||||||
|
|
||||||
pub fn change_wallpapers(wallpapers: &Wallpapers) {
|
pub fn change_wallpapers(_wallpapers: &Wallpapers) {
|
||||||
println!("Not implemented");
|
println!("Not implemented");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,4 @@
|
|||||||
pub mod dbus_plasma_interface;
|
pub mod dbus_plasma_interface;
|
||||||
use dbus_plasma_interface::*;
|
|
||||||
pub mod plasma;
|
|
||||||
use plasma::*;
|
|
||||||
pub mod feh;
|
pub mod feh;
|
||||||
use feh::*;
|
|
||||||
pub mod gnome;
|
pub mod gnome;
|
||||||
use gnome::*;
|
pub mod plasma;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user