Add autostart manager with XDG autostart support
This commit is contained in:
@@ -990,6 +990,39 @@ fn build_system_tab(record: &AppImageRecord, db: &Rc<Database>, toast_overlay: &
|
||||
integration_group.add(&row);
|
||||
}
|
||||
}
|
||||
// Autostart toggle
|
||||
let autostart_row = adw::SwitchRow::builder()
|
||||
.title("Start at login")
|
||||
.subtitle("Launch this app automatically when you log in")
|
||||
.active(record.autostart)
|
||||
.tooltip_text(
|
||||
"Creates an autostart entry so this app launches \
|
||||
when you log in to your desktop."
|
||||
)
|
||||
.build();
|
||||
let record_autostart = record.clone();
|
||||
let db_autostart = db.clone();
|
||||
let toast_autostart = toast_overlay.clone();
|
||||
let record_id_as = record.id;
|
||||
autostart_row.connect_active_notify(move |row| {
|
||||
if row.is_active() {
|
||||
match integrator::enable_autostart(&db_autostart, &record_autostart) {
|
||||
Ok(path) => {
|
||||
log::info!("Autostart enabled: {}", path.display());
|
||||
toast_autostart.add_toast(adw::Toast::new("Will start at login"));
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Failed to enable autostart: {}", e);
|
||||
toast_autostart.add_toast(adw::Toast::new("Failed to enable autostart"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
integrator::disable_autostart(&db_autostart, record_id_as).ok();
|
||||
toast_autostart.add_toast(adw::Toast::new("Autostart disabled"));
|
||||
}
|
||||
});
|
||||
integration_group.add(&autostart_row);
|
||||
|
||||
inner.append(&integration_group);
|
||||
|
||||
// Version Rollback group
|
||||
|
||||
Reference in New Issue
Block a user