diff --git a/src/app/panels/bottom.rs b/src/app/panels/bottom.rs index 9d8c0eb..57ffffe 100644 --- a/src/app/panels/bottom.rs +++ b/src/app/panels/bottom.rs @@ -5,6 +5,7 @@ use crate::disk::node::Node; use crate::disk::pool::Pool; use crate::disk::state::{Gupax, State}; use crate::disk::status::Submenu; +use crate::errors::process_running; use crate::helper::{Helper, ProcessSignal, ProcessState}; use crate::utils::constants::*; use crate::utils::errors::{ErrorButtons, ErrorFerris}; @@ -378,6 +379,9 @@ impl crate::app::App { ) { ui_enabled = false; text = format!("Error: {}", P2POOL_PATH_NOT_VALID); + } else if process_running(crate::helper::ProcessName::P2pool) { + ui_enabled = false; + text = format!("Error: {}", PROCESS_OUTSIDE); } ui.add_enabled_ui(ui_enabled, |ui| { let color = if ui_enabled { GREEN } else { RED }; @@ -530,6 +534,9 @@ impl crate::app::App { { ui_enabled = false; text = format!("Error: {}", XMRIG_PATH_NOT_VALID); + } else if process_running(crate::helper::ProcessName::Xmrig) { + ui_enabled = false; + text = format!("Error: {}", PROCESS_OUTSIDE); } ui.add_enabled_ui(ui_enabled, |ui| { let color = if ui_enabled { GREEN } else { RED }; @@ -729,6 +736,9 @@ impl crate::app::App { ) { ui_enabled = false; text = format!("Error: {}", XMRIG_PROXY_PATH_NOT_VALID); + } else if process_running(crate::helper::ProcessName::XmrigProxy) { + ui_enabled = false; + text = format!("Error: {}", PROCESS_OUTSIDE); } ui.add_enabled_ui(ui_enabled, |ui| { let color = if ui_enabled { GREEN } else { RED }; diff --git a/src/utils/constants.rs b/src/utils/constants.rs index 35537b0..4c42fa6 100644 --- a/src/utils/constants.rs +++ b/src/utils/constants.rs @@ -407,7 +407,6 @@ pub const LIST_ADD: &str = "Add the current values to the list"; pub const LIST_SAVE: &str = "Save the current values to the already existing entry"; pub const LIST_DELETE: &str = "Delete the currently selected entry"; pub const LIST_CLEAR: &str = "Clear all current values"; - // XMRig pub const XMRIG_SIMPLE: &str = r#"Use simple XMRig settings: - Mine to local P2Pool (localhost:3333) @@ -502,7 +501,8 @@ pub const BLOCK_PPLNS_WINDOW_MAIN: u64 = 363; pub const SECOND_PER_BLOCK_P2POOL: u64 = 10; // pub const TIME_PPLNS_WINDOW_MINI: Duration = Duration::from_secs(BLOCK_PPLNS_WINDOW_MINI * SECOND_PER_BLOCK_P2POOL); // pub const TIME_PPLNS_WINDOW_MAIN: Duration = Duration::from_secs(BLOCK_PPLNS_WINDOW_MAIN * SECOND_PER_BLOCK_P2POOL); - +pub const PROCESS_OUTSIDE: &str = + "This process is running outside of Gupaxx.\nYou need to stop it before starting it in Gupaxx."; //---------------------------------------------------------------------------------------------------- Visuals use egui::epaint::{Rounding, Shadow, Stroke}; diff --git a/src/utils/errors.rs b/src/utils/errors.rs index 0873058..fb887c1 100644 --- a/src/utils/errors.rs +++ b/src/utils/errors.rs @@ -1,9 +1,7 @@ use std::sync::{Arc, Mutex}; -#[cfg(target_os = "windows")] use sysinfo::System; -#[cfg(target_os = "windows")] use crate::helper::ProcessName; use super::sudo::SudoState; @@ -98,13 +96,11 @@ impl ErrorState { } } -#[cfg(target_os = "windows")] pub fn process_running(process_name: ProcessName) -> bool { let name = match process_name { ProcessName::P2pool => "p2pool", ProcessName::Xmrig => "xmrig", ProcessName::XmrigProxy => "xmrig-proxy", - ProcessName::Node => "monerod", ProcessName::Xvb => panic!("XvB does not exist as a process outside of Gupaxx"), }; let s = System::new_all();