aboutsummaryrefslogtreecommitdiff
path: root/pulse/src/config.rs
diff options
context:
space:
mode:
authorAndreas Grois <andi@grois.info>2021-05-01 22:16:54 +0200
committerAndreas Grois <andi@grois.info>2021-05-01 22:16:54 +0200
commit18a96163d730b7e44270603a4c6de071b725db5f (patch)
treee91e9d23eec5031d9be7f1422b147c05d44a25d7 /pulse/src/config.rs
parent00a3332d9a986f650283416dccf25aa9f2d32aa6 (diff)
First draft of pulse architecture.
Diffstat (limited to 'pulse/src/config.rs')
-rw-r--r--pulse/src/config.rs66
1 files changed, 66 insertions, 0 deletions
diff --git a/pulse/src/config.rs b/pulse/src/config.rs
new file mode 100644
index 0000000..77b2a22
--- /dev/null
+++ b/pulse/src/config.rs
@@ -0,0 +1,66 @@
+use serde::{Serialize,Deserialize};
+use std::collections::BTreeMap;
+use swaystatus_plugin::*;
+
+
+#[derive(Serialize, Deserialize)]
+#[serde(tag = "Sink")]
+enum Sink {
+ Default,
+ Specific {
+ sink_name : String
+ }
+}
+
+#[derive(Serialize, Deserialize)]
+#[serde(tag = "Format")]
+enum Volume {
+ Off,
+ Numeric {
+ label : String
+ },
+ Binned {
+ label: String,
+ bin_symbol_map : BTreeMap<u8,String>
+ }
+}
+
+#[derive(Serialize, Deserialize)]
+#[serde(tag = "Format")]
+enum Balance {
+ Off,
+ Numeric {
+ label : String
+ },
+ Binned {
+ label :String,
+ bin_symbol_map : BTreeMap<i8,String>
+ }
+}
+
+
+#[derive(Serialize, Deserialize)]
+#[serde(rename_all = "PascalCase", default)]
+pub struct PulseVolumeConfig {
+ sink : Sink,
+ volume : Volume,
+ balance : Balance
+}
+
+impl Default for PulseVolumeConfig {
+ fn default() -> Self {
+ PulseVolumeConfig {
+ sink : Sink::Default,
+ volume : Volume::Numeric { label : String::new()},
+ balance : Balance::Off
+ }
+ }
+}
+
+impl SwayStatusModuleInstance for PulseVolumeConfig {
+ fn make_runnable<'p>(&'p self,to_main : Box<dyn MsgModuleToMain + 'p>) -> (Box<dyn SwayStatusModuleRunnable + 'p>, Box<dyn MsgMainToModule + 'p>) {
+ let (runnable, sender_for_main) = crate::runnable::PulseVolumeRunnable::new(&self, to_main);
+ (Box::new(runnable), Box::new(sender_for_main))
+ }
+}
+