-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplate.go
32 lines (28 loc) · 856 Bytes
/
template.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
package usrCmds
func init() {
register("template", Template)
// onFocus(func(api DaemonAPI, win types.WindowData) {
// fmt.Println("template.focus")
// })
// onClose(func(api DaemonAPI, win types.WindowData) {
// fmt.Println("template.close")
// })
// onNew(func(api DaemonAPI, win types.WindowData) {
// fmt.Println("template.new")
// })
// onCopy(func(api DaemonAPI, text string) string {
// fmt.Println("template.copy")
// })
}
// Template is a template for creating new user commands, with some API examples.
func Template(d DaemonAPI, args map[string]string) (string, error) {
win := d.FocusedWindow()
path, err := d.GetWinTreePath(win.ID)
if err != nil {
return "", err
}
p("Focused window: %d", win.Title)
p("Focused workspace: %d", path[0].Name)
inspect(args)
return "cli output", d.SwayMsg(`exec echo %d`, win.ID)
}