Initial
This commit is contained in:
commit
c6874f3ef2
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/target
|
||||||
63
Cargo.lock
generated
Normal file
63
Cargo.lock
generated
Normal file
@ -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",
|
||||||
|
]
|
||||||
7
Cargo.toml
Normal file
7
Cargo.toml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[package]
|
||||||
|
name = "mycelium"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
untildify = "0.1.1"
|
||||||
107
src/config.rs
Normal file
107
src/config.rs
Normal file
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
7
src/main.rs
Normal file
7
src/main.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
mod config;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let config = config::Config::new();
|
||||||
|
|
||||||
|
println!("{}", config);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user