forked from blrsn/zentile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeybinding.go
76 lines (70 loc) · 1.72 KB
/
keybinding.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package main
import (
"github.com/BurntSushi/xgbutil"
"github.com/BurntSushi/xgbutil/keybind"
"github.com/BurntSushi/xgbutil/xevent"
"github.com/blrsn/zentile/state"
log "github.com/sirupsen/logrus"
)
type keyMapper struct{}
func (k keyMapper) bind(action string, f func()) {
err := keybind.KeyPressFun(
func(X *xgbutil.XUtil, ev xevent.KeyPressEvent) {
f()
}).Connect(state.X, state.X.RootWin(),
Config.Keybindings[action], true)
if err != nil {
log.Warn(err)
}
}
func bindKeys(t *tracker) {
workspaces := t.workspaces
keybind.Initialize(state.X)
k := keyMapper{}
k.bind("tile", func() {
ws := workspaces[state.CurrentDesk]
ws.IsTiling = true
ws.Tile()
})
k.bind("untile", func() {
ws := workspaces[state.CurrentDesk]
ws.Untile()
})
k.bind("make_active_window_master", func() {
c := t.clients[state.ActiveWin]
ws := workspaces[state.CurrentDesk]
ws.ActiveLayout().MakeMaster(c)
ws.Tile()
})
k.bind("switch_layout", func() {
workspaces[state.CurrentDesk].SwitchLayout()
})
k.bind("increase_master", func() {
ws := workspaces[state.CurrentDesk]
ws.ActiveLayout().IncMaster()
ws.Tile()
})
k.bind("decrease_master", func() {
ws := workspaces[state.CurrentDesk]
ws.ActiveLayout().DecreaseMaster()
ws.Tile()
})
k.bind("next_window", func() {
ws := workspaces[state.CurrentDesk]
ws.ActiveLayout().NextClient()
})
k.bind("previous_window", func() {
ws := workspaces[state.CurrentDesk]
ws.ActiveLayout().PreviousClient()
})
k.bind("increment_master", func() {
ws := workspaces[state.CurrentDesk]
ws.ActiveLayout().IncrementMaster()
ws.Tile()
})
k.bind("decrement_master", func() {
ws := workspaces[state.CurrentDesk]
ws.ActiveLayout().DecrementMaster()
ws.Tile()
})
}