-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
61 lines (50 loc) · 1.12 KB
/
main.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"log"
"github.com/AndreKR/multiface"
"github.com/BurntSushi/xgbutil"
"github.com/BurntSushi/xgbutil/xgraphics"
"github.com/markbates/pkger"
"github.com/onodera-punpun/oshirase"
)
var (
runtime = pkger.Dir("/runtime")
// Connection to the X server.
X *xgbutil.XUtil
// The multifont face that should be used.
face *multiface.Face
)
func main() {
// Initialize X.
if err := initX(); err != nil {
log.Fatalln(err)
}
// Initialize font face.
if err := initFace(); err != nil {
log.Fatalln(err)
}
// Initialize oshirase.
srv, err := oshirase.NewServer("melonnotifier", "onodera-punpun", "0.0.1")
if err != nil {
log.Fatalln(err)
}
// Initialize notification.
n, err := initNotification(1920-56, 1200-(56*2), 56, xgraphics.BGRA{
B: 238, G: 238, R: 238, A: 0xFF}, xgraphics.BGRA{B: 2, G: 27, R: 33,
A: 0xFF}, 4)
if err != nil {
log.Fatalln(err)
}
ns := newNotifies()
srv.OnNotify(func(o *oshirase.Notify) {
ns.add(o)
go n.show(o)
})
srv.OnCloseNotification(func(id uint32) bool {
if err := ns.delete(id); err != nil {
return false
}
return true
})
select {}
}