config: migrate cursor_hide_timeout to the grouped cursor_hide key
Reads the legacy key once at startup when the new one is absent, so the handful of people who set it by hand from the cosmic-settings#603 thread do not silently lose auto-hide. The old file is left on disk so a downgrade still finds it. Drafted with Claude (Anthropic); reviewed and tested by the committer.
This commit is contained in:
parent
6e0aea0eb2
commit
4e72d2ce98
1 changed files with 14 additions and 2 deletions
|
|
@ -10,7 +10,7 @@ use crate::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use cosmic_config::{ConfigGet, CosmicConfigEntry};
|
use cosmic_config::{ConfigGet, ConfigSet, CosmicConfigEntry};
|
||||||
use cosmic_settings_config::window_rules::ApplicationException;
|
use cosmic_settings_config::window_rules::ApplicationException;
|
||||||
use cosmic_settings_config::{Shortcuts, shortcuts, window_rules};
|
use cosmic_settings_config::{Shortcuts, shortcuts, window_rules};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
@ -182,7 +182,7 @@ impl Config {
|
||||||
.expect("Failed to add cosmic-config to the event loop");
|
.expect("Failed to add cosmic-config to the event loop");
|
||||||
let xdg = xdg::BaseDirectories::new();
|
let xdg = xdg::BaseDirectories::new();
|
||||||
|
|
||||||
let cosmic_comp_config =
|
let mut cosmic_comp_config =
|
||||||
CosmicCompConfig::get_entry(&config).unwrap_or_else(|(errs, c)| {
|
CosmicCompConfig::get_entry(&config).unwrap_or_else(|(errs, c)| {
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
for err in errs {
|
for err in errs {
|
||||||
|
|
@ -192,6 +192,18 @@ impl Config {
|
||||||
c
|
c
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// `cursor_hide_timeout` was replaced by the grouped `cursor_hide` key.
|
||||||
|
// Seed the new key once so configs hand-edited before the rename keep
|
||||||
|
// working; the old file is left in place so a downgrade still reads it.
|
||||||
|
if config.get::<CursorHideConfig>("cursor_hide").is_err()
|
||||||
|
&& let Ok(legacy) = config.get::<Option<u32>>("cursor_hide_timeout")
|
||||||
|
{
|
||||||
|
cosmic_comp_config.cursor_hide.idle_timeout = legacy;
|
||||||
|
if let Err(err) = config.set("cursor_hide", cosmic_comp_config.cursor_hide) {
|
||||||
|
warn!(?err, "Failed to migrate cursor_hide_timeout to cursor_hide");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Listen for updates to the toolkit config
|
// Listen for updates to the toolkit config
|
||||||
if let Ok(tk_config) = cosmic_config::Config::new("com.system76.CosmicTk", 1) {
|
if let Ok(tk_config) = cosmic_config::Config::new("com.system76.CosmicTk", 1) {
|
||||||
fn handle_new_toolkit_config(config: CosmicTk, state: &mut State) {
|
fn handle_new_toolkit_config(config: CosmicTk, state: &mut State) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue