Initial
This commit is contained in:
commit
c6874f3ef2
5 files changed
+185
No files matched your search
+107
@@ -0,0 +1,107 @@
|
||||
use core::fmt;
|
||||
|
||||
use untildify;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum WallpaperHandler {
|
||||
Feh,
|
||||
Plasma,
|
||||
Gnome,
|
||||
}
|
||||
|
||||
impl fmt::Display for WallpaperHandler {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum MonitorType {
|
||||
Ultrawide,
|
||||
Horizontal,
|
||||
Vertical,
|
||||
}
|
||||
|
||||
impl fmt::Display for MonitorType {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Monitors {
|
||||
monitors: Vec<MonitorType>,
|
||||
}
|
||||
|
||||
impl Monitors {
|
||||
pub fn new() -> Monitors {
|
||||
Monitors {
|
||||
monitors: vec![MonitorType::Vertical],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Monitors {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "[")?;
|
||||
for v in &self.monitors {
|
||||
write!(f, "{}", v)?;
|
||||
}
|
||||
write!(f, "]")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct WallpaperDir {
|
||||
ultrawide: String,
|
||||
horizontal: String,
|
||||
vertical: String,
|
||||
}
|
||||
|
||||
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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for WallpaperDir {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"ultrawide: {ultrawide}, horizontal {horizontal}, vertical {vertical}",
|
||||
ultrawide = self.ultrawide,
|
||||
horizontal = self.horizontal,
|
||||
vertical = self.vertical
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Config {
|
||||
pub x_server: String,
|
||||
pub wallpaper_engine: WallpaperHandler,
|
||||
pub wallpaper_dir: WallpaperDir,
|
||||
pub monitors: Monitors,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn new() -> Config {
|
||||
Config {
|
||||
x_server: String::new(),
|
||||
wallpaper_engine: WallpaperHandler::Plasma,
|
||||
wallpaper_dir: WallpaperDir::new(),
|
||||
monitors: Monitors::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Config {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
mod config;
|
||||
|
||||
fn main() {
|
||||
let config = config::Config::new();
|
||||
|
||||
println!("{}", config);
|
||||
}
|
||||
Reference in new issue
Block a user