feat(cosmic-theme): add color schemes for qt apps

This commit is contained in:
Adil Hanney 2026-02-17 16:39:37 +00:00 committed by GitHub
parent 6328c40ef7
commit a2e903ad94
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 677 additions and 3 deletions

View file

@ -163,9 +163,19 @@ impl Theme {
std::fs::create_dir_all(&config_dir).map_err(OutputError::Io)?;
}
let mut file = File::create(config_dir.join(name)).map_err(OutputError::Io)?;
file.write_all(css_str.as_bytes())
.map_err(OutputError::Io)?;
let file_path = config_dir.join(name);
let tmp_file_path = config_dir.join(name.to_owned() + "~");
// Write to tmp_file_path first, then move it to file_path
let mut tmp_file = File::create(&tmp_file_path).map_err(OutputError::Io)?;
let res = tmp_file
.write_all(css_str.as_bytes())
.and_then(|_| tmp_file.flush())
.and_then(|_| std::fs::rename(&tmp_file_path, file_path));
if let Err(e) = res {
_ = std::fs::remove_file(&tmp_file_path);
return Err(OutputError::Io(e));
}
Ok(())
}