-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (36 loc) · 912 Bytes
/
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
// Prints active window's parents and children for default screeen.
package main
import (
"fmt"
"log"
"github.com/jezek/xgo"
)
func main() {
d, err := xgo.OpenDisplay("")
if err != nil {
fmt.Println(err)
return
}
fmt.Println("Display name:", d.Name())
fmt.Println("Number of screens:", d.NumberOfScreens())
fmt.Println("Number of desktops:", d.NumberOfDesktops())
fmt.Println()
fmt.Println("Active window status:")
a := d.ActiveWindow()
aps, err := a.Parents()
if err != nil {
log.Println("Can't get active window parents,", err)
}
achs, err := a.Children()
if err != nil {
log.Println("Can't get active window children,", err)
}
for i := len(aps) - 1; i >= 0; i-- {
fmt.Printf("%s - %s\n", aps[i], aps[i].Name())
}
fmt.Printf("* active %s - %s\n", a, a.Name())
for i := len(achs) - 1; i >= 0; i-- {
fmt.Printf("|- %s - %s\n", achs[i], achs[i].Name())
}
fmt.Println()
}