From 0fbd4574ef4caf74769a617d205fd1fc909ac9b1 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Tue, 22 Sep 2026 14:41:11 -0400 Subject: [PATCH] fix: skip loading shortcuts for kiosk mode --- src/config/mod.rs | 70 ++++++++++++++++++++++++++--------------------- src/state.rs | 2 +- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/src/config/mod.rs b/src/config/mod.rs index 4d2fad9b..f8a51585 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -172,7 +172,7 @@ pub enum ColorFilter { } impl Config { - pub fn load(loop_handle: &LoopHandle<'_, State>) -> Config { + pub fn load(loop_handle: &LoopHandle<'_, State>, kiosk_mode: bool) -> Config { let config = cosmic_config::Config::new("com.system76.CosmicComp", 1).unwrap(); let source = cosmic_config::calloop::ConfigWatchSource::new(&config).unwrap(); loop_handle @@ -248,40 +248,48 @@ impl Config { // Source key bindings from com.system76.CosmicSettings.Shortcuts let settings_context = shortcuts::context().expect("Failed to load shortcuts config"); - let system_actions = shortcuts::system_actions(&settings_context); - let shortcuts = shortcuts::shortcuts(&settings_context); + let mut system_actions = Default::default(); + let mut shortcuts = Default::default(); + // Kiosk mode disables shortcuts + if !kiosk_mode { + system_actions = shortcuts::system_actions(&settings_context); + shortcuts = shortcuts::shortcuts(&settings_context); - // Listen for updates to the keybindings config. - match cosmic_config::calloop::ConfigWatchSource::new(&settings_context) { - Ok(source) => { - if let Err(err) = loop_handle.insert_source(source, |(config, keys), (), state| { - for key in keys { - match key.as_str() { - // Reload the keyboard shortcuts config. - "custom" | "defaults" => { - state.common.config.shortcuts = shortcuts::shortcuts(&config); + // Listen for updates to the keybindings config. + match cosmic_config::calloop::ConfigWatchSource::new(&settings_context) { + Ok(source) => { + if let Err(err) = + loop_handle.insert_source(source, |(config, keys), (), state| { + for key in keys { + match key.as_str() { + // Reload the keyboard shortcuts config. + "custom" | "defaults" => { + state.common.config.shortcuts = + shortcuts::shortcuts(&config); + } + + "system_actions" => { + state.common.config.system_actions = + shortcuts::system_actions(&config); + } + + _ => (), + } } - - "system_actions" => { - state.common.config.system_actions = - shortcuts::system_actions(&config); - } - - _ => (), - } + }) + { + warn!( + ?err, + "Failed to watch com.system76.CosmicSettings.Shortcuts config" + ); } - }) { - warn!( - ?err, - "Failed to watch com.system76.CosmicSettings.Shortcuts config" - ); } - } - Err(err) => warn!( - ?err, - "failed to create config watch source for com.system76.CosmicSettings.Shortcuts" - ), - }; + Err(err) => warn!( + ?err, + "failed to create config watch source for com.system76.CosmicSettings.Shortcuts" + ), + }; + } let window_rules_context = window_rules::context().expect("Failed to load window rules config"); diff --git a/src/state.rs b/src/state.rs index d605c736..86f5e23e 100644 --- a/src/state.rs +++ b/src/state.rs @@ -667,7 +667,7 @@ impl State { .unwrap(); let clock = Clock::new(); - let config = Config::load(&handle); + let config = Config::load(&handle, kiosk_command.is_some()); let compositor_state = CompositorState::new::(dh); let corner_radius_state = CornerRadiusState::new::(dh); let data_device_state = DataDeviceState::new::(dh);