-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsway_window.go
More file actions
42 lines (33 loc) · 775 Bytes
/
Copy pathsway_window.go
File metadata and controls
42 lines (33 loc) · 775 Bytes
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
package blocks
import (
"context"
"github.com/kraftwerk28/gost/blocks/ipc"
. "github.com/kraftwerk28/gost/core"
)
type SwayWindowConfig struct {
}
type SwayWindow struct {
name string
}
func NewSwayWindow() I3barBlocklet {
return &SwayWindow{}
}
// func (s *SwayWindow) GetConfig() interface{} {
// return nil
// }
func (t *SwayWindow) Run(ch UpdateChan, ctx context.Context) {
client, _ := ipc.NewIpcClient()
client.SendRaw(ipc.IpcMsgTypeSubscribe, []byte(`["window"]`))
client.Recv()
for {
_, m, _ := client.Recv()
t.name = m.(*ipc.WindowChange).Container.Name
ch.SendUpdate()
}
}
func (t *SwayWindow) Render(cfg *AppConfig) []I3barBlock {
return []I3barBlock{{FullText: t.name}}
}
func init() {
RegisterBlocklet("sway_window", NewSwayWindow)
}