Skip to content
Snippets Groups Projects

WIP: (conditional) addition of SSD installation page, some code-reorganizations, fix of stack sidebar tabbing, exit directly without cleanup script

Open plom requested to merge plom_experiments into main
2 files
+ 20
18
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 15
17
@@ -23,6 +23,14 @@ const WELCOME_IMG_WIDTH: i32 = 640/2;
const WELCOME_IMG_HEIGHT: i32 = 534/2;
const CSS_CLASS_TITLE: &str = "title-3";
const PATH_MODEL: &str = "/proc/device-tree/model";
const PATH_NVME: &str = "/dev/nvme0n1";
const LEGAL_MODELS: [&str; 3] = [
"MNT Pocket Reform with RCORE RK3588 Module",
"MNT Reform 2 with RCORE RK3588 Module",
"MNT Reform Next with RCORE RK3588 Module",
];
const PATH_ETC_DEFAULT_KEYBOARD: &str = "/etc/default/keyboard";
const TEMPLATE_ETC_DEFAULT_KEYBOARD: &str = r#"# KEYBOARD CONFIGURATION FILE
@@ -42,7 +50,7 @@ const TEMPLATE_ETC_HOSTS: &str = r#"127.0.0.1 localhost ${HOSTNAME}
::1 localhost ip6-localhost ip6-loopback ${HOSTNAME}
"#;
const DESKTOP_BINARIES : [&str; 2] = [ "sway", "wayfire" ];
const DESKTOP_BINARIES: [&str; 2] = [ "sway", "wayfire" ];
const PATH_ETC_GREETD_CONFIG: &str = "/etc/greetd/config.toml";
const TEMPLATE_ETC_GREETD_CONFIG: &str = r#"[terminal]
# The VT to run the greeter on. Can be "next", "current" or a number
@@ -103,24 +111,14 @@ fn valid_username(name: &str) -> bool {
}
fn get_device_model() -> String {
match fs::read_to_string("/proc/device-tree/model") {
match fs::read_to_string(PATH_MODEL) {
Ok(s) => s,
Err(_) => "Unknown Device".to_string()
}
}
fn get_nvme() -> Option<String> {
let dev_dir = "/dev";
let prefix = "nvme";
for entry in fs::read_dir(dev_dir).unwrap() {
let path = entry.unwrap().path();
if let Some(file_name) = path.file_name() {
if file_name.to_string_lossy().starts_with(prefix) {
return Some(path.display().to_string())
}
}
}
None
fn check_ssd_installability() -> bool {
LEGAL_MODELS.contains(&&*get_device_model()) && std::path::Path::new(PATH_NVME).exists()
}
fn parse_keyboard_layout_file(file_path: &str) -> HashMap<String, XkbVariant> {
@@ -979,9 +977,9 @@ fn build_ui(app: &Application) {
let _desktop_page = build_desktop_page(&stack, desktop_choice.clone());
let _root_pw_page = build_root_pw_page(&stack);
let _hostname_page = build_hostname_page(&stack);
let got_nvme = match get_nvme() { Some(_) => true, _ => false };
let _account_page = build_account_page(&stack, desktop_choice.clone(), &window, got_nvme);
if got_nvme {
let ssd_installable = check_ssd_installability();
let _account_page = build_account_page(&stack, desktop_choice.clone(), &window, ssd_installable);
if ssd_installable {
build_ssd_install_page(&stack, &window);
}
Loading