From 7e190c3aafd7b7c14af126368f8c35ef150bbf54 Mon Sep 17 00:00:00 2001 From: Andreas Grois Date: Thu, 22 Apr 2021 20:44:06 +0200 Subject: Change format for clock refresh rate once more. It's now optional again, but needs its own block. --- TODO | 7 +++++++ clock/src/lib.rs | 7 +++---- testconfig | 6 ++++-- 3 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 TODO diff --git a/TODO b/TODO new file mode 100644 index 0000000..62b91b1 --- /dev/null +++ b/TODO @@ -0,0 +1,7 @@ +o) Factor out lib- and plugin-loading in a way that still gives a vector of libs, but an Iterator over the plugins (so caller can choose if Vec or something else) +o) Add --plugin-help parameter that takes a list of plugins for which to display help (or if none given for all of them). This also means changing the Plugin trait once more. +o) Add --list-plugins parameter that just lists all loaded plugins. + +Clock: +o) Add a corrective sleep of 1 ms if rounding errors are detected at startup or manual update. (current time + 1 ms rounds to a different update-fraction than current time) +o) Change configuration format. Instead of directly entering seconds as a float, update rate should be "how often to update within 30 minutes" as u16. That way the _data type_ already enforces the precision limits :D diff --git a/clock/src/lib.rs b/clock/src/lib.rs index da4ee94..79426ce 100644 --- a/clock/src/lib.rs +++ b/clock/src/lib.rs @@ -77,14 +77,14 @@ impl<'c> SwayStatusModuleRunnable for ClockRunnable<'c> { /// maximum update rate was chosen to be way below 1/ms. By coincidence a 16 bit integer fits the /// range of reasonable values nicely. #[derive(Serialize, Deserialize)] -#[serde(untagged)] +#[serde(tag = "Synchronization")] enum ClockRefreshRate { NotSynchronized { - #[serde(rename = "UnsyncedEverySeconds")] + #[serde(rename = "Seconds")] seconds : f32 }, UTCSynchronized { - #[serde(rename = "UTCSyncedUpdatesPerThirtyMinutes")] + #[serde(rename = "PerThirtyMinutes")] updates_per_thirty_minutes : u16 } } @@ -93,7 +93,6 @@ enum ClockRefreshRate { #[serde(rename_all = "PascalCase",default)] struct ClockConfig { format : String, - #[serde(flatten)] refresh_rate : ClockRefreshRate } diff --git a/testconfig b/testconfig index 79d92c5..a1de210 100644 --- a/testconfig +++ b/testconfig @@ -6,11 +6,13 @@ Plugin = "ClockPlugin" [Elements.Config] Format = "%+" -UTCSyncedUpdatesPerThirtyMinutes = 1800 [[Elements]] Plugin = "ClockPlugin" [Elements.Config] Format = "%+" -UnsyncedEverySeconds = 10.0 + +[Elements.Config.RefreshRate] +Synchronization = "UTCSynchronized" +PerThirtyMinutes = 3600 -- cgit v1.2.3