fix: skip loading shortcuts for kiosk mode
This commit is contained in:
parent
d36480c1b5
commit
0fbd4574ef
2 changed files with 40 additions and 32 deletions
|
|
@ -172,7 +172,7 @@ pub enum ColorFilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
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 config = cosmic_config::Config::new("com.system76.CosmicComp", 1).unwrap();
|
||||||
let source = cosmic_config::calloop::ConfigWatchSource::new(&config).unwrap();
|
let source = cosmic_config::calloop::ConfigWatchSource::new(&config).unwrap();
|
||||||
loop_handle
|
loop_handle
|
||||||
|
|
@ -248,40 +248,48 @@ impl Config {
|
||||||
|
|
||||||
// Source key bindings from com.system76.CosmicSettings.Shortcuts
|
// Source key bindings from com.system76.CosmicSettings.Shortcuts
|
||||||
let settings_context = shortcuts::context().expect("Failed to load shortcuts config");
|
let settings_context = shortcuts::context().expect("Failed to load shortcuts config");
|
||||||
let system_actions = shortcuts::system_actions(&settings_context);
|
let mut system_actions = Default::default();
|
||||||
let shortcuts = shortcuts::shortcuts(&settings_context);
|
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.
|
// Listen for updates to the keybindings config.
|
||||||
match cosmic_config::calloop::ConfigWatchSource::new(&settings_context) {
|
match cosmic_config::calloop::ConfigWatchSource::new(&settings_context) {
|
||||||
Ok(source) => {
|
Ok(source) => {
|
||||||
if let Err(err) = loop_handle.insert_source(source, |(config, keys), (), state| {
|
if let Err(err) =
|
||||||
for key in keys {
|
loop_handle.insert_source(source, |(config, keys), (), state| {
|
||||||
match key.as_str() {
|
for key in keys {
|
||||||
// Reload the keyboard shortcuts config.
|
match key.as_str() {
|
||||||
"custom" | "defaults" => {
|
// Reload the keyboard shortcuts config.
|
||||||
state.common.config.shortcuts = shortcuts::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 =
|
warn!(
|
||||||
shortcuts::system_actions(&config);
|
?err,
|
||||||
}
|
"Failed to watch com.system76.CosmicSettings.Shortcuts config"
|
||||||
|
);
|
||||||
_ => (),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}) {
|
|
||||||
warn!(
|
|
||||||
?err,
|
|
||||||
"Failed to watch com.system76.CosmicSettings.Shortcuts config"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
Err(err) => warn!(
|
||||||
Err(err) => warn!(
|
?err,
|
||||||
?err,
|
"failed to create config watch source for com.system76.CosmicSettings.Shortcuts"
|
||||||
"failed to create config watch source for com.system76.CosmicSettings.Shortcuts"
|
),
|
||||||
),
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
let window_rules_context =
|
let window_rules_context =
|
||||||
window_rules::context().expect("Failed to load window rules config");
|
window_rules::context().expect("Failed to load window rules config");
|
||||||
|
|
|
||||||
|
|
@ -667,7 +667,7 @@ impl State {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let clock = Clock::new();
|
let clock = Clock::new();
|
||||||
let config = Config::load(&handle);
|
let config = Config::load(&handle, kiosk_command.is_some());
|
||||||
let compositor_state = CompositorState::new::<Self>(dh);
|
let compositor_state = CompositorState::new::<Self>(dh);
|
||||||
let corner_radius_state = CornerRadiusState::new::<Self>(dh);
|
let corner_radius_state = CornerRadiusState::new::<Self>(dh);
|
||||||
let data_device_state = DataDeviceState::new::<Self>(dh);
|
let data_device_state = DataDeviceState::new::<Self>(dh);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue