Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- import "errors"
- import "code.google.com/p/x-go-binding/xgb"
- func main() {
- // open the connection to the default X server
- display, err := xgb.Dial("")
- if err != nil {
- panic(errors.New("unable to open X server"))
- }
- // get the root window
- screen := display.DefaultScreen()
- root := screen.Root
- // intern the "WM_NAME" atom
- atomTitle, err := display.InternAtom(false, "WM_NAME")
- if err != nil {
- panic(errors.New("unable to intern WM_NAME"))
- }
- // get the list of windows
- tree, err := display.QueryTree(root)
- if err != nil {
- panic(errors.New("unable to get the tree of windows"))
- }
- // display the title and ID of each window
- for _, child := range tree.Children {
- title, err := display.GetProperty(false, child, atomTitle.Atom, xgb.GetPropertyTypeAny, 0, 1024)
- if err != nil {
- panic(errors.New("unable to get window title"))
- }
- fmt.Println("found window", child, string(title.Value))
- }
- }
Add Comment
Please, Sign In to add comment