bugfix: add version to user daemon. Fix multiple anime config

This commit is contained in:
Luke D. Jones
2021-04-26 15:49:35 +12:00
parent 41cbf4d353
commit c67373a830
9 changed files with 23 additions and 14 deletions
+3 -1
View File
@@ -16,7 +16,9 @@ use std::sync::atomic::AtomicBool;
static ANIME_INNER_EARLY_RETURN: AtomicBool = AtomicBool::new(false);
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!(" rog-dbus version {}", rog_dbus::VERSION);
println!("user daemon v{}", rog_user::VERSION);
println!(" rog-anime v{}", rog_anime::VERSION);
println!(" rog-dbus v{}", rog_dbus::VERSION);
let (client, _) = AuraDbusClient::new().unwrap();
let supported = client.proxies().supported().get_supported_functions()?;
+2
View File
@@ -7,3 +7,5 @@ pub mod ctrl_anime;
pub mod zbus_anime;
pub static DBUS_NAME: &str = "org.asuslinux.Daemon";
pub static VERSION: &str = env!("CARGO_PKG_VERSION");
+4 -6
View File
@@ -63,7 +63,7 @@ impl UserAnimeConfig {
create_dir(path.clone())?;
}
path.push(name + ".cfg");
path.push(name.clone() + ".cfg");
let mut file = OpenOptions::new()
.read(true)
@@ -75,7 +75,7 @@ impl UserAnimeConfig {
if let Ok(read_len) = file.read_to_string(&mut buf) {
if read_len == 0 {
let default = UserAnimeConfig::default();
let default = UserAnimeConfig { name, ..Default::default() };
let json = serde_json::to_string_pretty(&default).unwrap();
file.write_all(json.as_bytes())?;
return Ok(default);
@@ -89,7 +89,7 @@ impl UserAnimeConfig {
impl Default for UserAnimeConfig {
fn default() -> Self {
let x = Self {
Self {
name: "default".to_string(),
anime: vec![
AnimeAction::AsusAnimation {
@@ -122,9 +122,7 @@ impl Default for UserAnimeConfig {
time: AnimTime::Cycles(2),
},
],
};
println!("{}", serde_json::to_string_pretty(&x).unwrap());
x
}
}
}