aboutsummaryrefslogtreecommitdiff
path: root/src/types.rs
blob: 99e0701dcc70219f6476649472e0637cabed39df (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
use breadx::{display::*, window::Window};

#[derive(Debug, Clone)]
pub enum ThreadsData {
    Mpd(String),
    Sound(String),
    Disk(String),
    Memory(String),
    Time(String),
    Weather(String),
    Battery(String),
    CpuTemp(String),
    Uptime(String),
    Spotify(String),
}

#[derive(Clone)]
pub struct Config {
    pub seperator: String,
    pub time: Time,
    pub memory: Memory,
    pub disk: Disk,
    pub volume: Volume,
    pub weather: Weather,
    pub battery: Battery,
    pub cpu_temperature: CpuTemp,
    pub uptime: Uptime,
    pub mpd: Mpd,
    pub spotify: Spotify,
}

#[derive(Clone)]
pub struct Time {
    pub format: String,
    pub icon: String,
    pub delay: f64,
}

#[derive(Clone)]
pub struct Memory {
    pub icon: String,
    pub enabled: bool,
    pub delay: f64,
}

#[derive(Clone)]
pub struct Disk {
    pub icon: String,
    pub enabled: bool,
    pub delay: f64,
}
#[derive(Clone)]
pub struct Volume {
    pub icon: String,
    pub enabled: bool,
    pub delay: f64,
    pub card: String,
}

#[derive(Clone)]
pub struct Weather {
    pub city: String,
    pub format: String,
    pub icon: String,
    pub enabled: bool,
    pub delay: f64,
}

#[derive(Clone)]
pub struct Battery {
    pub source: String,
    pub icon: String,
    pub enabled: bool,
    pub delay: f64,
}

#[derive(Clone)]
pub struct CpuTemp {
    pub icon: String,
    pub enabled: bool,
    pub delay: f64,
}

#[derive(Clone)]
pub struct Uptime {
    pub icon: String,
    pub enabled: bool,
    pub delay: f64,
}

#[derive(Clone)]
pub struct Mpd {
    pub icon: String,
    pub host: String,
    pub port: String,
    pub enabled: bool,
    pub delay: f64,
}

#[derive(Clone)]
pub struct Spotify {
    pub icon: String,
    pub enabled: bool,
    pub delay: f64,
}

pub struct Blocks {
    pub disp: Display<name::NameConnection>,
    pub root: Window,
}

impl Blocks {
    pub fn new() -> Self {
        let disp = Display::create(None, None).expect("Failed to create x11 connection");
        let root = disp.default_screen().root;
        Self { disp, root }
    }
}

impl Default for Blocks {
    fn default() -> Self {
        Self::new()
    }
}