From c6874f3ef29d90f1e397c9353cf6449f9cb1fdc0 Mon Sep 17 00:00:00 2001 From: Benjamyn Love Date: Sat, 9 Mar 2024 21:41:16 +1100 Subject: [PATCH] Initial --- .gitignore | 1 + Cargo.lock | 63 +++++++++++++++++++++++++++++ Cargo.toml | 7 ++++ src/config.rs | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 7 ++++ 5 files changed, 185 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/config.rs create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..eb915a0 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,63 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "mycelium" +version = "0.1.0" +dependencies = [ + "untildify", +] + +[[package]] +name = "regex" +version = "1.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "untildify" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "992d9e1100cf171942054a07eef9a04986cc8acdb1f771be47accaa301a46bb7" +dependencies = [ + "regex", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..aa60f22 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "mycelium" +version = "0.1.0" +edition = "2021" + +[dependencies] +untildify = "0.1.1" diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..590c89e --- /dev/null +++ b/src/config.rs @@ -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, +} + +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) + } +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..4dc7245 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,7 @@ +mod config; + +fn main() { + let config = config::Config::new(); + + println!("{}", config); +}