redo project structure and add logic for desktop setup

axtloss/rework-partitioning
Amy 3 years ago
parent 8624a1c287
commit 73f0801b0d
No known key found for this signature in database
GPG Key ID: C642EA4B2F4096BE

1
.gitignore vendored

@ -1 +1,2 @@
/target
Cargo.lock

@ -0,0 +1,35 @@
use crate::internal::*;
pub fn choose_pkgs(desktop_setup: &str) {
println!("Installing {}", desktop_setup);
match desktop_setup {
"onyx" => {
install(vec!("onyx", "lightdm", "lightdm-gtk-greeter", "lightdm-gtk-greeter-settings"));
}
"gnome" => {
install(vec!("gnome","gnome-tweaks","chrome-gnome-shell","gdm"));
},
"kde" => {
install(vec!("kde", "plasma", "plasma-wayland-session", "kde-applications", "sddm"));
},
"budgie" => {
install(vec!("budgie-desktop", "gnome", "lightdm", "lightdm-gtk-greeter", "lightdm-gtk-greeter-settings"));
},
"cinnamon" => {
install(vec!("cinnamon", "lightdm", "lightdm-gtk-greeter", "lightdm-gtk-greeter-settings", "metacity", "gnome-shell"));
},
"mate" => {
install(vec!("mate", "lightdm", "lightdm-gtk-greeter", "lightdm-gtk-greeter-settings", "mate-extra"));
},
"xfce" => {
install(vec!("xfce4", "lightdm", "lightdm-gtk-greeter", "lightdm-gtk-greeter-settings", "xfce4-goodies"));
},
"enlightenment" => {
install(vec!("enlightenment", "lightdm", "lightdm-gtk-greeter", "lightdm-gtk-greeter-settings", "terminology"));
},
_ => {
crash("Unknown desktop setup".to_string(), 1);
}
}
}

@ -1,45 +0,0 @@
pub fn choose_pkgs(desktop_setup: &str, de: &str, dm: &str) {
if desktop_setup == "custom" {
install_desktop(de, dm);
} else {
println!("Installing {}", desktop_setup);
match desktop_setup {
"onyx" => {
install_desktop("onyx", "lightdm");
}
"gnome" => {
install_desktop("gnome", "gdm");
},
"kde" => {
install_desktop("kde", "sddm");
},
"budgie" => {
install_desktop("budgie", "lightdm");
},
"cinnamon" => {
install_desktop("cinnamon", "lightdm");
},
"mate" => {
install_desktop("mate", "lightdm");
},
"xfce" => {
install_desktop("xfce", "lightdm");
},
"pantheon" => {
install_desktop("pantheon", "lightdm");
},
"enlightenment" => {
install_desktop("enlightenment", "lightdm");
},
_ => {
println!("Unknown desktop setup");
}
}
}
}
fn install_desktop(de: &str, dm: &str) {
println!("Installing {}", de);
println!("Installing {}", dm);
}

@ -0,0 +1,5 @@
use std::process::Command;
pub fn install(pkgs: Vec<&str>) {
Command::new("pacman").arg("-S").args(pkgs).output().expect("Failed to install packages");
}

@ -0,0 +1,37 @@
pub mod install;
pub mod strings;
pub fn install(pkgs: Vec<&str>) {
install::install(pkgs);
}
pub fn info(a: String) {
strings::info(a);
}
pub fn crash(a: String, b: i32) {
strings::crash(a, b);
}
pub fn log(a: String) {
strings::log(a);
}
pub fn prompt(a: String, b: bool) -> bool {
strings ::prompt(a, b)
}
#[macro_export]
macro_rules! uwu {
($x:expr) => {{
let uwu: String = String::from_str($x).unwrap();
let uwu = uwu.replace("l", "w");
let uwu = uwu.replace("L", "W");
let uwu = uwu.replace("r", "w");
let uwu = uwu.replace("R", "W");
let uwu = uwu.replace("na", "nya");
let uwu = uwu.replace("Na", "Nya");
let uwu = uwu.replace("NA", "NYA");
uwu
}};
}

@ -0,0 +1,63 @@
use std::{env, io};
use std::io::Write;
use std::process::exit;
use std::str::FromStr;
use std::time::UNIX_EPOCH;
use crate::uwu;
pub fn info(a: String) {
let a = if env::var("JADE_UWU").unwrap_or_else(|_| "".to_string()) == "true" {
uwu!(&a)
} else {
a
};
println!("\x1b[2;22;35m❖\x1b[0m \x1b[1;37m{}\x1b[0m", a)
}
pub fn crash(a: String, b: i32) {
let a = if env::var("JADE_UWU").unwrap_or_else(|_| "".to_string()) == "true" {
uwu!(&a)
} else {
a
};
println!("\x1b[2;22;31m❌:\x1b[0m \x1b[1;91m{}\x1b[0m", a);
exit(b);
}
pub fn log(a: String) {
let a = if env::var("JADE_UWU").unwrap_or_else(|_| "".to_string()) == "true"
&& env::var("JADE_UWU_DEBUG").unwrap_or_else(|_| "".to_string()) == "true"
{
uwu!(&a)
} else {
a
};
eprintln!(
"{} {}",
std::time::SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs(),
a
);
}
pub fn prompt(a: String, b: bool) -> bool {
let default = ["[Y/n]", "[y/N]"];
let i = if b { 0 } else { 1 };
let a = if env::var("JADE_UWU").unwrap_or_else(|_| "".to_string()) == "true" {
uwu!(&a)
} else {
a
};
print!(
"\x1b[2;22;35m?\x1b[0m \x1b[1;37m{}\x1b[0m \x1b[2;22;37m{}\x1b[0m: ",
a, default[i]
);
let mut yn: String = String::new();
io::stdout().flush().ok();
let _ = std::io::stdin().read_line(&mut yn);
if yn.trim().to_lowercase() == "n" || yn.trim().to_lowercase() == "no" {
false
} else if yn.trim().to_lowercase() == "y" || yn.trim().to_lowercase() == "yes" {
true
} else {
b
}
}

@ -1,6 +1,7 @@
mod installer;
mod functions;
mod internal;
use crate::installer::*;
use crate::functions::*;
use clap::{App, Arg, SubCommand};
fn main() {
@ -96,17 +97,7 @@ fn main() {
Arg::with_name("desktopsetup")
.help("The desktop setup to use")
.required(true),
)
.arg(
Arg::with_name("de")
.help("The Desktop envionment to install (only read if desktopsetup is set to custom)")
.required_if("desktopsetup", "custom"),
)
.arg(
Arg::with_name("dm")
.help("The Display Manager to install (only read if desktopsetup is set to custom)")
.required_if("desktopsetup", "custom"),
),
),
).get_matches();
@ -131,7 +122,7 @@ fn main() {
users::root_pass(app.value_of("rootPass").unwrap());
}
} else if let Some(app) = app.subcommand_matches("desktops") {
desktops::choose_pkgs(app.value_of("desktopsetup").unwrap(), app.value_of("de").unwrap_or("none"), app.value_of("dm").unwrap_or("none"));
desktops::choose_pkgs(app.value_of("desktopsetup").unwrap());
} else {
println!("Running TUI installer");
}

Loading…
Cancel
Save