-
Notifications
You must be signed in to change notification settings - Fork 0
/
bluetooth.go
46 lines (37 loc) · 941 Bytes
/
bluetooth.go
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
package main
import (
"barista.run/bar"
"barista.run/colors"
"barista.run/modules/bluetooth"
"barista.run/modules/meta/split"
"barista.run/outputs"
"barista.run/pango"
)
func bluetoothAudio(adapter, address, icon string) (bar.Module, bar.Module) {
return split.New(bluetooth.Device(adapter, address).Output(func(b bluetooth.DeviceInfo) bar.Output {
out := outputs.Group()
color := colorOn
iconAppendix := ""
if !b.Connected {
color = colorOff
iconAppendix = "-off"
}
// summary
out.Append(outputs.Pango(
pango.Icon("mdi-" + icon + iconAppendix).Alpha(0.6).Color(colors.Hex(color)),
))
// detail
out.Append(outputs.Pango(
pango.Icon("mdi-"+icon).Alpha(0.6).Color(colors.Hex(color)),
spacer,
pango.Text(b.Name),
))
if b.Connected {
out.Append(outputs.Pango(
pango.Icon("mdi-battery").Alpha(0.6),
pango.Textf("%s: %d%%", b.Alias, b.Battery),
))
}
return out
}), 1)
}