a lightweight, interval-based utility to combat digital strain through "Ma" (intentional pauses) for the eyes and body.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: wire autostart toggle

+14 -5
-3
src/autostart.rs
··· 1 1 use anyhow::Result; 2 2 use auto_launch::AutoLaunch; 3 3 4 - #[allow(dead_code)] 5 4 fn launcher() -> Result<AutoLaunch> { 6 5 let exe = std::env::current_exe()?; 7 6 Ok(AutoLaunch::new("ioma", exe.to_str().unwrap_or("ioma"), &[] as &[&str])) 8 7 } 9 8 10 - #[allow(dead_code)] 11 9 pub fn set_enabled(enabled: bool) -> Result<()> { 12 10 let al = launcher()?; 13 11 if enabled { ··· 20 18 Ok(()) 21 19 } 22 20 23 - #[allow(dead_code)] 24 21 pub fn is_enabled() -> bool { 25 22 launcher() 26 23 .and_then(|al| al.is_enabled().map_err(|e| anyhow::anyhow!("{e}")))
+11 -1
src/main.rs
··· 93 93 { 94 94 let win = settings_mgr.window().clone_strong(); 95 95 let cfg_arc = state.cfg.clone(); 96 + let settings_ref = Rc::clone(&settings_mgr); 96 97 settings_mgr.window().on_save_clicked(move || { 97 - let cfg = cfg_arc.lock().unwrap().clone(); 98 + let mut cfg = cfg_arc.lock().unwrap().clone(); 99 + // Pull widget state back into config before saving. 100 + settings_ref.read_into(&mut cfg); 101 + *cfg_arc.lock().unwrap() = cfg.clone(); 102 + 103 + // Apply autostart immediately. 104 + if let Err(e) = autostart::set_enabled(cfg.app.autostart) { 105 + log::warn!("Autostart toggle failed: {e}"); 106 + } 107 + 98 108 win.hide().unwrap_or_default(); 99 109 config::save(&cfg).unwrap_or_else(|e| log::warn!("save failed: {e}")); 100 110 });
+3 -1
src/settings/mod.rs
··· 1 1 use slint::{ModelRc, SharedString, VecModel}; 2 2 3 + use crate::autostart; 3 4 use crate::config::{AppConfig, BreakModeConfig}; 4 5 use crate::generated::SettingsWindow; 5 6 ··· 59 60 window.set_enforced_mode(enforced); 60 61 window.set_sound_enabled(cfg.appearance.sound_enabled); 61 62 window.set_sound_volume(cfg.appearance.sound_volume); 62 - window.set_autostart(cfg.app.autostart); 63 + // Reflect actual OS state rather than last-saved config value. 64 + window.set_autostart(autostart::is_enabled()); 63 65 64 66 let idle_prof = cfg.profiles.get(&cfg.app.active_profile); 65 67 window.set_idle_detection_enabled(idle_prof.map_or(true, |p| p.idle_detection_enabled));