1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
use serde::{Serialize,Deserialize};
use std::collections::BTreeMap;
use swaystatus_plugin::*;
#[derive(Serialize, Deserialize)]
#[serde(tag = "Sink")]
pub enum Sink {
Default,
Specific {
sink_name : String
}
}
#[derive(Serialize, Deserialize)]
#[serde(tag = "Format")]
pub enum Volume {
Off,
Numeric {
label : String
},
Binned {
label: String,
bin_symbol_map : BTreeMap<u8,String>
}
}
#[derive(Serialize, Deserialize)]
#[serde(tag = "Format")]
pub 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 {
pub sink : Sink,
pub volume : Volume,
pub 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))
}
}
|