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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
use std::collections::HashMap;
use ratatui::style::Color;
use crate::{action::Action, utils::widget::generate_id, widget::{ContainerFlex, CoverArtResize, Direction, FumWidget, LabelAlignment, ProgressOption}};
use super::{keybind::Keybind, Align};
pub fn players() -> Vec<String> { vec!["spotify".to_string()] }
pub fn use_active_player() -> bool { false }
pub fn fps() -> u64 { 10 }
pub fn align() -> Align { Align::Center }
pub fn direction() -> Direction { Direction::Vertical }
pub fn flex() -> ContainerFlex { ContainerFlex::Start }
pub fn width() -> u16 { 19 }
pub fn height() -> u16 { 15 }
pub fn border() -> bool { false }
pub fn padding() -> [u16; 2] { [0, 0] }
pub fn bg() -> Color { Color::Reset }
pub fn fg() -> Color { Color::Reset }
pub fn cover_art_ascii() -> String { "".to_string() }
pub fn keybinds() -> HashMap<Keybind, Action> {
HashMap::from([
(Keybind::Many([Keybind::Esc, Keybind::Char('q')].to_vec()), Action::Quit),
(Keybind::Char('h'), Action::Prev),
(Keybind::Char('l'), Action::Next),
(Keybind::Char(' '), Action::PlayPause)
])
}
pub fn layout() -> Vec<FumWidget> {
Vec::from([
FumWidget::CoverArt {
width: None,
height: None,
border: false,
resize: CoverArtResize::Scale,
bg: None,
fg: None,
},
FumWidget::Empty {
size: 1,
bg: None,
fg: None
},
FumWidget::Container {
width: None,
height: None,
direction: Direction::Vertical,
border: false,
padding: padding(),
flex: ContainerFlex::default(),
bg: None,
fg: None,
children: Vec::from([
FumWidget::Label {
text: "$title".to_string(),
direction: Direction::default(),
align: LabelAlignment::Center,
truncate: true,
bold: false,
bg: None,
fg: None
},
FumWidget::Label {
text: "$artists".to_string(),
direction: Direction::default(),
align: LabelAlignment::Center,
truncate: true,
bold: false,
bg: None,
fg: None
},
FumWidget::Empty {
size: 1,
bg: None,
fg: None
},
FumWidget::Container {
width: None,
height: Some(1),
direction: Direction::Horizontal,
border: false,
padding: padding(),
flex: ContainerFlex::SpaceAround,
bg: None,
fg: None,
children: Vec::from([
FumWidget::Button {
id: generate_id(),
text: "".to_string(),
direction: Direction::default(),
action: Some(Action::Prev),
action_secondary: None,
exec: None,
bold: false,
bg: None,
fg: None
},
FumWidget::Button {
id: generate_id(),
text: "$status-icon".to_string(),
direction: Direction::default(),
action: Some(Action::PlayPause),
action_secondary: None,
exec: None,
bold: false,
bg: None,
fg: None
},
FumWidget::Button {
id: generate_id(),
text: "".to_string(),
direction: Direction::default(),
action: Some(Action::Next),
action_secondary: None,
exec: None,
bold: false,
bg: None,
fg: None
}
])
},
FumWidget::Progress {
id: generate_id(),
size: None,
direction: Direction::Horizontal,
progress: ProgressOption {
char: '',
bg: None,
fg: None
},
empty: ProgressOption {
char: '',
bg: None,
fg: None
}
},
FumWidget::Container {
width: None,
height: Some(1),
border: false,
padding: padding(),
direction: Direction::Horizontal,
flex: ContainerFlex::SpaceBetween,
bg: None,
fg: None,
children: Vec::from([
FumWidget::Label {
text: "$position".to_string(),
direction: Direction::default(),
align: LabelAlignment::Left,
truncate: false,
bold: false,
bg: None,
fg: None
},
FumWidget::Label {
text: "$length".to_string(),
direction: Direction::default(),
align: LabelAlignment::Right,
truncate: false,
bold: false,
bg: None,
fg: None
}
])
}
])
}
])
}