": "Restart",
+ "": "Shutdown",
"": "OpenTerminal",
"": "Quit",
"": "Quit",
diff --git a/core/Cargo.toml b/core/Cargo.toml
index e724ecf..8d99e89 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -1,17 +1,17 @@
-# This file is part of Deja-vu.
+# This file is part of Deja-Vu.
#
-# Deja-vu is free software: you can redistribute it and/or modify it
+# Deja-Vu is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
-# Deja-vu is distributed in the hope that it will be useful, but
+# Deja-Vu is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with Deja-vu. If not, see .
+# along with Deja-Vu. If not, see .
[package]
name = "core"
@@ -42,6 +42,7 @@ lazy_static = "1.5.0"
libc = "0.2.158"
once_cell = "1.20.2"
pretty_assertions = "1.4.0"
+rand = "0.9.0"
ratatui = { version = "0.29.0", features = ["serde", "macros"] }
raw-cpuid = "11.2.0"
regex = "1.11.1"
diff --git a/core/build.rs b/core/build.rs
index c3ced6b..8988d39 100644
--- a/core/build.rs
+++ b/core/build.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
use anyhow::Result;
use vergen_gix::{BuildBuilder, CargoBuilder, Emitter, GixBuilder};
diff --git a/core/src/action.rs b/core/src/action.rs
index 604edd7..486cdbb 100644
--- a/core/src/action.rs
+++ b/core/src/action.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
use serde::{Deserialize, Serialize};
use strum::Display;
@@ -20,6 +20,8 @@ use crate::{components::popup::Type, line::DVLine, state::Mode, system::disk::Di
#[derive(Debug, Clone, PartialEq, Eq, Display, Serialize, Deserialize)]
pub enum Action {
+ // App (Boot-Diags)
+ BootScan,
// App (Clone)
Highlight(usize),
InstallDriver,
@@ -27,6 +29,7 @@ pub enum Action {
ScanDisks,
Select(Option, Option), // indicies for (source, dest) etc
SelectRight(Option, Option), // indicies for right info pane
+ TasksComplete,
UpdateDiskList(Vec),
UpdateFooter(String),
UpdateLeft(String, Vec, Vec, usize), // (title, labels, items, select_num)
@@ -35,8 +38,10 @@ pub enum Action {
// 1: For a single choice
// 2: For two selections (obviously)
UpdateRight(Vec>, usize, Vec>), // (labels, start_index, items) - items before start are always shown
- // App (PEMenu)
+ // App (PE-Menu)
OpenTerminal,
+ Restart,
+ Shutdown,
// Screens
DismissPopup,
DisplayPopup(Type, String),
diff --git a/core/src/cli.rs b/core/src/cli.rs
index be4d597..f154dfe 100644
--- a/core/src/cli.rs
+++ b/core/src/cli.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
use clap::Parser;
diff --git a/core/src/components.rs b/core/src/components.rs
index 6d1fd97..e46c56a 100644
--- a/core/src/components.rs
+++ b/core/src/components.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
use color_eyre::Result;
use crossterm::event::{KeyEvent, MouseEvent};
diff --git a/core/src/components/footer.rs b/core/src/components/footer.rs
index 7355961..d266be2 100644
--- a/core/src/components/footer.rs
+++ b/core/src/components/footer.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
use color_eyre::Result;
use ratatui::{
diff --git a/core/src/components/fps.rs b/core/src/components/fps.rs
index cdb822e..32e4770 100644
--- a/core/src/components/fps.rs
+++ b/core/src/components/fps.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
use std::time::Instant;
diff --git a/core/src/components/left.rs b/core/src/components/left.rs
index 0f1c833..eb27244 100644
--- a/core/src/components/left.rs
+++ b/core/src/components/left.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
use color_eyre::Result;
use crossterm::event::KeyEvent;
@@ -138,14 +138,10 @@ impl Component for Left {
.areas(area);
// Title
- let title_text = if self.selections[1].is_some() || self.select_num == 1 {
- "Confirm Selections"
- } else {
- self.title_text.as_str()
- };
- let title =
- Paragraph::new(Line::from(Span::styled(title_text, Style::default())).centered())
- .block(Block::default().borders(Borders::NONE));
+ let title = Paragraph::new(
+ Line::from(Span::styled(self.title_text.as_str(), Style::default())).centered(),
+ )
+ .block(Block::default().borders(Borders::NONE));
frame.render_widget(title, title_area);
// Body (Blank)
diff --git a/core/src/components/popup.rs b/core/src/components/popup.rs
index c2c0980..4b951a7 100644
--- a/core/src/components/popup.rs
+++ b/core/src/components/popup.rs
@@ -1,19 +1,20 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
use color_eyre::Result;
+use rand::random;
use ratatui::{
prelude::*,
widgets::{Block, Borders, Clear, Paragraph, Wrap},
@@ -95,3 +96,19 @@ impl Component for Popup {
Ok(())
}
}
+
+pub fn fortune() -> String {
+ String::from(match random::() / 4 {
+ 0 => "FUN FACT\n\n\nComputers barely work.",
+ 1 => "CRASH OVERRIDE\n\n\n\"Hack the planet!\"",
+ 2 => "CATS\n\n\n\"All your base are belong to us!\"",
+ 3 => "HMM\n\n\nThis has all happened before...\n\nThis will all happen again.",
+ 4 => "CYPHER\n\n\n\"I don’t even see the code. All I see is blonde, brunette, red-head.\"",
+ 5 => "CONGRATULATIONS\n\n\nYour did it!",
+ 6 => "DID YOU KNOW?\n\n\nmacOS includes a built-in screen reader!",
+ 7 => "TIP OF THE DAY\n\n\nNever go full Snappy!",
+ 8 => "WORDS OF WISDOM\n\n\n\nIt’s not DNS,\n\nThere’s no way it’s DNS,\n\nIt was DNS.",
+ 9 => "HAL 9000\n\n\n\"I'm sorry Dave, I'm afraid I can't do that.\"",
+ _ => "COMPLETE\n\n\nThank you for using this tool!",
+ })
+}
diff --git a/core/src/components/right.rs b/core/src/components/right.rs
index 569d0a1..e7c18b6 100644
--- a/core/src/components/right.rs
+++ b/core/src/components/right.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
use color_eyre::Result;
use crossterm::event::KeyEvent;
diff --git a/core/src/components/state.rs b/core/src/components/state.rs
index b7b139c..d2862a9 100644
--- a/core/src/components/state.rs
+++ b/core/src/components/state.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
use std::collections::HashMap;
@@ -55,7 +55,7 @@ impl StatefulList {
self.state.selected()
}
- fn select_first_item(&mut self) {
+ pub fn select_first_item(&mut self) {
if self.items.is_empty() {
self.state.select(None);
} else {
diff --git a/core/src/components/title.rs b/core/src/components/title.rs
index ee4f088..f8e7dee 100644
--- a/core/src/components/title.rs
+++ b/core/src/components/title.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
use color_eyre::Result;
use ratatui::{
diff --git a/core/src/config.rs b/core/src/config.rs
index 49eb824..2878c20 100644
--- a/core/src/config.rs
+++ b/core/src/config.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
#![allow(dead_code)] // Remove this once you start using the code
@@ -149,8 +149,8 @@ pub fn get_config_dir() -> PathBuf {
}
fn project_directory() -> Option {
- ProjectDirs::from("com", "Deja-vu", "deja-vu")
- //ProjectDirs::from("com", "Deja-vu", env!("CARGO_PKG_NAME"))
+ ProjectDirs::from("com", "Deja-Vu", "deja-vu")
+ //ProjectDirs::from("com", "Deja-Vu", env!("CARGO_PKG_NAME"))
}
#[derive(Clone, Debug, Default, Deref, DerefMut)]
diff --git a/core/src/errors.rs b/core/src/errors.rs
index 6d1753f..6285edc 100644
--- a/core/src/errors.rs
+++ b/core/src/errors.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
use std::env;
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 2e49e5e..f954f22 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
pub mod action;
pub mod cli;
diff --git a/core/src/line.rs b/core/src/line.rs
index 038a848..c618451 100644
--- a/core/src/line.rs
+++ b/core/src/line.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
use ratatui::{
style::{Color, Style},
@@ -45,7 +45,10 @@ impl DVLine {
}
}
-pub fn get_disk_description_right(disk: &Disk) -> Vec {
+pub fn get_disk_description_right(
+ disk: &Disk,
+ boot_os_indicies: Option>,
+) -> Vec {
let mut description: Vec = vec![
DVLine {
line_parts: vec![format!(
@@ -67,12 +70,29 @@ pub fn get_disk_description_right(disk: &Disk) -> Vec {
line_colors: vec![Color::Blue],
},
];
- for line in &disk.parts_description {
- description.push(DVLine {
- line_parts: vec![line.clone()],
- line_colors: vec![Color::Reset],
+ disk.parts_description
+ .iter()
+ .enumerate()
+ .for_each(|(index, line)| {
+ let mut line_parts = vec![line.clone()];
+ let mut line_colors = vec![Color::Reset];
+ if let Some(indicies) = &boot_os_indicies {
+ let boot_index = indicies.get(0);
+ if boot_index.is_some_and(|i| i == &index) {
+ line_parts.push(String::from(" <-- Boot Partition"));
+ line_colors.push(Color::Cyan);
+ }
+ let boot_index = indicies.get(1);
+ if boot_index.is_some_and(|i| i == &index) {
+ line_parts.push(String::from(" <-- OS Partition"));
+ line_colors.push(Color::Cyan);
+ }
+ }
+ description.push(DVLine {
+ line_parts,
+ line_colors,
+ });
});
- }
description
}
diff --git a/core/src/logging.rs b/core/src/logging.rs
index 741e981..02c8b3a 100644
--- a/core/src/logging.rs
+++ b/core/src/logging.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
use color_eyre::Result;
use tracing_error::ErrorLayer;
diff --git a/core/src/state.rs b/core/src/state.rs
index fab9ede..8c8eb8d 100644
--- a/core/src/state.rs
+++ b/core/src/state.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
use std::sync::{Arc, Mutex};
@@ -30,6 +30,13 @@ pub enum Mode {
Home,
Done,
Failed,
+ // Boot Diags
+ DiagMenu,
+ BootDiags,
+ BootScan,
+ BootSetup,
+ InjectDrivers,
+ SetBootMode,
// Clone
ScanDisks,
InstallDrivers,
diff --git a/core/src/system.rs b/core/src/system.rs
index 1d9692d..f8c5db1 100644
--- a/core/src/system.rs
+++ b/core/src/system.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
pub mod boot;
pub mod cpu;
diff --git a/core/src/system/boot.rs b/core/src/system/boot.rs
index 2bc098f..3a87d2d 100644
--- a/core/src/system/boot.rs
+++ b/core/src/system/boot.rs
@@ -1,33 +1,40 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
use super::{disk::PartitionTableType, drivers::Driver};
-use crate::tasks::Task;
+use crate::tasks::TaskType;
use color_eyre::Result;
use std::path::PathBuf;
+#[derive(Clone, Debug, Default)]
+pub enum SafeMode {
+ #[default]
+ Disable,
+ Enable,
+}
+
pub fn configure_disk(
letter_boot: &str,
letter_os: &str,
system32: &str,
table_type: PartitionTableType,
-) -> Vec {
+) -> Vec {
let mut tasks = Vec::new();
// Create
- tasks.push(Task::Command(
+ tasks.push(TaskType::CommandWait(
PathBuf::from(format!("{system32}/bcdboot.exe")),
vec![
format!("{letter_os}:\\Windows"),
@@ -43,7 +50,7 @@ pub fn configure_disk(
// Update boot sector (for legacy setups)
if table_type == PartitionTableType::Legacy {
- tasks.push(Task::Command(
+ tasks.push(TaskType::CommandWait(
PathBuf::from(format!("{system32}/bootsect.exe")),
vec![
String::from("/nt60"),
@@ -55,34 +62,19 @@ pub fn configure_disk(
}
// Lock in safe mode
- let bcd_path = match table_type {
- PartitionTableType::Guid => {
- format!("{letter_boot}:\\EFI\\Microsoft\\Boot\\BCD")
- }
- PartitionTableType::Legacy => {
- format!("{letter_boot}:\\Boot\\BCD")
- }
- };
- tasks.push(Task::Command(
- PathBuf::from(format!("{system32}/bcdedit.exe")),
- vec![
- String::from("/store"),
- bcd_path,
- String::from("/set"),
- String::from("{default}"),
- String::from("safeboot"),
- String::from("minimal"),
- ],
- ));
+ tasks.push(
+ set_mode(letter_boot, SafeMode::Enable, system32, &table_type)
+ .expect("Failed to create set_mode task."),
+ );
// Done
tasks
}
-pub fn inject_driver(driver: &Driver, letter_os: &str, system32: &str) -> Result {
+pub fn inject_driver(driver: &Driver, letter_os: &str, system32: &str) -> Result {
//if let Some(driver_path_str) = driver.path.to_str() {
let driver_path = driver.path.to_str().unwrap();
- Ok(Task::Command(
+ Ok(TaskType::CommandWait(
PathBuf::from(format!("{system32}/dism.exe")),
vec![
format!("/image:{letter_os}:\\"),
@@ -92,3 +84,39 @@ pub fn inject_driver(driver: &Driver, letter_os: &str, system32: &str) -> Result
],
))
}
+
+pub fn set_mode(
+ letter_boot: &str,
+ mode: SafeMode,
+ system32: &str,
+ table_type: &PartitionTableType,
+) -> Result {
+ let bcd_path = match table_type {
+ PartitionTableType::Guid => {
+ format!("{letter_boot}:\\EFI\\Microsoft\\Boot\\BCD")
+ }
+ PartitionTableType::Legacy => {
+ format!("{letter_boot}:\\Boot\\BCD")
+ }
+ };
+
+ // Build CommandWait
+ let mut cmd_args = vec![String::from("/store"), bcd_path];
+ match mode {
+ SafeMode::Disable => {
+ cmd_args.push(String::from("/deletevalue"));
+ cmd_args.push(String::from("{default}"));
+ cmd_args.push(String::from("safeboot"));
+ }
+ SafeMode::Enable => {
+ cmd_args.push(String::from("/set"));
+ cmd_args.push(String::from("{default}"));
+ cmd_args.push(String::from("safeboot"));
+ cmd_args.push(String::from("minimal"));
+ }
+ }
+ Ok(TaskType::CommandWait(
+ PathBuf::from(format!("{system32}/bcdedit.exe")),
+ cmd_args,
+ ))
+}
diff --git a/core/src/system/cpu.rs b/core/src/system/cpu.rs
index 1187d2c..0e2a316 100644
--- a/core/src/system/cpu.rs
+++ b/core/src/system/cpu.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
#[must_use]
pub fn get_cpu_name() -> String {
diff --git a/core/src/system/disk.rs b/core/src/system/disk.rs
index 96a8ae0..3450add 100644
--- a/core/src/system/disk.rs
+++ b/core/src/system/disk.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
use serde::{Deserialize, Serialize};
use std::{
diff --git a/core/src/system/diskpart.rs b/core/src/system/diskpart.rs
index 9521982..ae1c97a 100644
--- a/core/src/system/diskpart.rs
+++ b/core/src/system/diskpart.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
use std::{
collections::HashMap,
@@ -129,7 +129,7 @@ pub fn get_partition_details(
#[must_use]
pub fn build_dest_format_script(disk_id: usize, part_type: &PartitionTableType) -> String {
let disk_id = format!("{disk_id}");
- let mut script = vec!["select disk {disk_id}", "clean"];
+ let mut script = vec!["automount enable noerr", "select disk {disk_id}", "clean"];
match part_type {
PartitionTableType::Guid => {
script.push("convert gpt");
diff --git a/core/src/system/drivers.rs b/core/src/system/drivers.rs
index a95c342..8ddfa6c 100644
--- a/core/src/system/drivers.rs
+++ b/core/src/system/drivers.rs
@@ -1,17 +1,17 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
use std::{env, fmt, fs::read_dir, path::PathBuf, process::Command};
diff --git a/core/src/tasks.rs b/core/src/tasks.rs
index 50bca0d..b0bd7a9 100644
--- a/core/src/tasks.rs
+++ b/core/src/tasks.rs
@@ -1,21 +1,22 @@
-// This file is part of Deja-vu.
+// This file is part of Deja-Vu.
//
-// Deja-vu is free software: you can redistribute it and/or modify it
+// Deja-Vu is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// Deja-vu is distributed in the hope that it will be useful, but
+// Deja-Vu is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with Deja-vu. If not, see .
+// along with Deja-Vu. If not, see .
//
use std::{
collections::VecDeque,
+ fmt,
path::PathBuf,
process::{Command, Stdio},
sync::{Arc, Mutex},
@@ -34,23 +35,69 @@ use crate::{
};
#[derive(Clone, Debug)]
-pub enum Task {
- Command(PathBuf, Vec), // (command, args)
- Diskpart(String), // (script_as_string)
+pub enum TaskResult {
+ Error(String),
+ Output(String, String, bool), // stdout, stderr, success
+}
+
+#[derive(Clone, Debug)]
+pub enum TaskType {
+ CommandNoWait(PathBuf, Vec), // (command, args)
+ CommandWait(PathBuf, Vec), // (command, args)
+ Diskpart(String), // (script_as_string)
ScanDisks,
Sleep,
UpdateDestDisk(usize), // (disk_index)
UpdateDiskList,
}
+impl fmt::Display for TaskType {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match self {
+ TaskType::CommandNoWait(cmd_path, _) | TaskType::CommandWait(cmd_path, _) => {
+ write!(
+ f,
+ "Command(\"{}\")",
+ cmd_path.file_name().unwrap().to_string_lossy()
+ )
+ }
+ TaskType::Diskpart(_) => {
+ write!(f, "Diskpart")
+ }
+ TaskType::ScanDisks => write!(f, "ScanDisks"),
+ TaskType::Sleep => write!(f, "Sleep"),
+ TaskType::UpdateDestDisk(_) => write!(f, "UpdateDestDisk"),
+ TaskType::UpdateDiskList => write!(f, "UpdateDiskList"),
+ }
+ }
+}
+
+#[derive(Debug)]
+pub struct Task {
+ pub handle: Option>,
+ pub result: Option,
+ pub task_type: TaskType,
+}
+
+impl Task {
+ pub fn new(task_type: TaskType) -> Task {
+ Task {
+ handle: None,
+ result: None,
+ task_type,
+ }
+ }
+}
+
#[derive(Debug)]
pub struct Tasks {
action_tx: mpsc::UnboundedSender,
disk_list: Arc>>,
- handle: Option>,
+ cur_handle: Option>,
+ cur_task: Option,
task_list: VecDeque,
- task_rx: mpsc::UnboundedReceiver, // Used to forward Actions from Tasks to App
- task_tx: mpsc::UnboundedSender, // Used to forward Actions from Tasks to App
+ task_rx: mpsc::UnboundedReceiver,
+ task_tx: mpsc::UnboundedSender,
}
impl Tasks {
@@ -62,159 +109,181 @@ impl Tasks {
Tasks {
action_tx,
disk_list: disk_list_arc,
- handle: None,
+ cur_handle: None,
+ cur_task: None,
task_list: VecDeque::new(),
task_rx,
task_tx,
}
}
- pub fn add(&mut self, task: Task) {
- info!("Adding task: {:?}", &task);
- self.task_list.push_back(task);
+ pub fn add(&mut self, task_type: TaskType) {
+ info!("Adding task: {:?}", &task_type);
+ self.task_list.push_back(Task::new(task_type));
}
pub fn idle(&self) -> bool {
- self.handle.is_none()
+ self.cur_handle.is_none()
}
- pub fn poll(&mut self) -> Result<()> {
- // Forward any actions to main app
- if let Ok(action) = self.task_rx.try_recv() {
- let result = self.action_tx.send(action.clone());
- assert!(result.is_ok(), "Failed to send Action: {action:?}");
+ pub fn poll(&mut self) -> Result