Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/pages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ fn create_apps_section() -> Option<gtk::Box> {
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);
Expand Down Expand Up @@ -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());
});
Expand Down
14 changes: 14 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
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"];
Expand Down