Add system-wide installation via pkexec with polkit policy

This commit is contained in:
lashman
2026-02-28 00:11:57 +02:00
parent c622057830
commit 27eb9f259d
4 changed files with 231 additions and 0 deletions

View File

@@ -1017,6 +1017,55 @@ fn build_system_tab(record: &AppImageRecord, db: &Rc<Database>, toast_overlay: &
});
integration_group.add(&wm_class_row);
// System-wide install toggle
if record.integrated {
let syswide_row = adw::SwitchRow::builder()
.title("Install system-wide")
.subtitle(if record.system_wide {
"Installed for all users in /opt/driftwood-apps/"
} else {
"Make available to all users on this computer"
})
.active(record.system_wide)
.tooltip_text(
"Copies the AppImage and its shortcut to system directories \
so all users on this computer can access it. Requires \
administrator privileges."
)
.build();
let record_sw = record.clone();
let db_sw = db.clone();
let toast_sw = toast_overlay.clone();
let record_id_sw = record.id;
syswide_row.connect_active_notify(move |row| {
if row.is_active() {
match integrator::install_system_wide(&record_sw, &db_sw) {
Ok(()) => {
toast_sw.add_toast(adw::Toast::new("Installed system-wide"));
}
Err(e) => {
log::error!("System-wide install failed: {}", e);
toast_sw.add_toast(adw::Toast::new("System-wide install failed"));
row.set_active(false);
}
}
} else {
match integrator::remove_system_wide(&db_sw, record_id_sw) {
Ok(()) => {
toast_sw.add_toast(adw::Toast::new("System-wide install removed"));
}
Err(e) => {
log::error!("Failed to remove system-wide install: {}", e);
toast_sw.add_toast(adw::Toast::new("Failed to remove system-wide install"));
row.set_active(true);
}
}
}
});
integration_group.add(&syswide_row);
}
inner.append(&integration_group);
// Version Rollback group