From 5156d7f051ac0783141b449c64b2a81d52a2ed02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pontus=20M=C3=A5rdn=C3=A4s?= Date: Thu, 16 Apr 2026 21:13:14 +0200 Subject: [PATCH 1/2] Unify checking if cachyos-pi is installed --- src/pages/mod.rs | 6 +++--- src/utils.rs | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/pages/mod.rs b/src/pages/mod.rs index c611211..9f5f510 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); @@ -289,8 +289,8 @@ pub fn create_appbrowser_page(builder: &Builder) { // 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"]; From f4858aa0a710659f7d29ea84441c98a62aaf8842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pontus=20M=C3=A5rdn=C3=A4s?= Date: Thu, 16 Apr 2026 21:14:54 +0200 Subject: [PATCH 2/2] Only show "Install programs" button if cachyos-pi is installed. --- src/pages/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/mod.rs b/src/pages/mod.rs index 9f5f510..07b9a3f 100644 --- a/src/pages/mod.rs +++ b/src/pages/mod.rs @@ -283,7 +283,7 @@ 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.