diff --git a/src/pages/mod.rs b/src/pages/mod.rs index c611211..07b9a3f 100644 --- a/src/pages/mod.rs +++ b/src/pages/mod.rs @@ -196,7 +196,7 @@ fn create_apps_section() -> Option { label.set_text(&fl!("applications")); // Check first btn. - if Path::new("/sbin/cachyos-pi").exists() { + if utils::is_cachyos_pi_installed() { let cachyos_pi = gtk::Button::with_label("CachyOS PackageInstaller"); cachyos_pi.connect_clicked(on_appbtn_clicked); box_collection.pack_start(&cachyos_pi, true, true, 2); @@ -283,14 +283,14 @@ pub fn create_tweaks_page(builder: &Builder) { pub fn create_appbrowser_page(builder: &Builder) { let install: gtk::Button = builder.object("appBrowser").unwrap(); - install.set_visible(true); + install.set_visible(utils::is_cachyos_pi_installed()); install.set_label(&fl!("appbrowser-label")); install.connect_clicked(move |_| { // Spawn child process in separate thread. std::thread::spawn(move || { // Get executable path. - let exec_path = "/usr/bin/cachyos-pi"; - let exit_status = utils::spawn_detached(exec_path).expect("Failed to spawn process"); + let exec_path = utils::get_cachyos_pi_path().expect("Did not find cachyos-pi"); + let exit_status = utils::spawn_detached(exec_path.as_str()).expect("Failed to spawn process"); debug!("Exit status successfully? = {:?}", exit_status.success()); }); diff --git a/src/utils.rs b/src/utils.rs index ef0cc91..e852c4e 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -174,6 +174,20 @@ pub fn is_alpm_pkg_installed(package_name: &str) -> bool { alpm.localdb().pkg(package_name.as_bytes()).is_ok() } +pub fn get_cachyos_pi_path() -> Option { + if Path::new("/usr/bin/cachyos-pi").exists() { + Some("/usr/bin/cachyos-pi"); + } + if Path::new("/sbin/cachyos-pi").exists() { + Some("/sbin/cachyos-pi"); + } + None +} + +pub fn is_cachyos_pi_installed() -> bool { + get_cachyos_pi_path().is_some() +} + pub fn is_intel_amd_gpu(vendor_id: &str, class_id: &str) -> bool { const GPU_CLASS_IDS: &[&str] = &["0300"]; const VENDOR_IDS: &[&str] = &["8086", "1002"];