func (x Xorg) ActiveWindow() Window {
	return x.activeWindow
}
ActiveWindow returns the currently active window
package main
import (
	"bytes"
	"errors"
	"image"
	"log"
	"time"
	"github.com/BurntSushi/xgb"
	"github.com/BurntSushi/xgb/screensaver"
	"github.com/BurntSushi/xgb/xproto"
	"github.com/BurntSushi/xgbutil"
	"github.com/BurntSushi/xgbutil/ewmh"
	"github.com/BurntSushi/xgbutil/xgraphics"
)
type Xorg struct {
	conn         *xgb.Conn
	util         *xgbutil.XUtil
	root         xproto.Window
	activeAtom   *xproto.InternAtomReply
	netNameAtom  *xproto.InternAtomReply
	nameAtom     *xproto.InternAtomReply
	classAtom    *xproto.InternAtomReply
	activeWindow Window
}
type ActiveWindowChangedEvent struct {
	Window Window
}
type WindowClosedEvent struct {
	Window Window
}
type Window struct {
	ID    uint32
	Class string
	Name  string
	Icon  image.Image
}
var (
	ErrNoValue = errors.New("empty value")
	ErrNoClass = errors.New("empty class")
)
func Connect(display string) Xorg {
	var x Xorg
	var err error
	x.conn, err = xgb.NewConnDisplay(display)
	if err != nil {
		log.Fatal("xgb:", err)
	}
	x.util, err = xgbutil.NewConnDisplay(display)
	if err != nil {
		log.Fatal(err)
	}
	err = screensaver.Init(x.conn)
	if err != nil {
		log.Fatal("screensaver:", err)
	}
	setup := xproto.Setup(x.conn)
	x.root = setup.DefaultScreen(x.conn).Root
	drw := xproto.Drawable(x.root)
	screensaver.SelectInput(x.conn, drw, screensaver.EventNotifyMask)
	x.activeAtom = x.atom("_NET_ACTIVE_WINDOW")
	x.netNameAtom = x.atom("_NET_WM_NAME")
	x.nameAtom = x.atom("WM_NAME")
	x.classAtom = x.atom("WM_CLASS")
	x.spy(x.root)
	return x
}
func (x Xorg) Close() {
	x.util.Conn().Close()
	x.conn.Close()
}
func (x *Xorg) TrackWindows(ch chan interface{}, timeout time.Duration) {
	if win, ok := x.window(); ok {
		x.activeWindow = win
		if ch != nil {
			go func() {
				ch <- ActiveWindowChangedEvent{
					Window: win,
				}
			}()
		}
	}
	events := make(chan xgb.Event, 1)
	go x.waitForEvent(events)
	go func() {
		for {
			select {
			case event := <-events:
				switch e := event.(type) {
				case xproto.DestroyNotifyEvent:
					ch <- WindowClosedEvent{
						Window: Window{
							ID: uint32(e.Window),
						},
					}
				case xproto.PropertyNotifyEvent:
					if win, ok := x.window(); ok {
						if win.ID != x.activeWindow.ID {
							x.activeWindow = win
							if ch != nil {
								go func() {
									ch <- ActiveWindowChangedEvent{
										Window: win,
									}
								}()
							}
						}
					}
				case screensaver.NotifyEvent:
					switch e.State {
					case screensaver.StateOn:
					default:
					}
				}
			case <-time.After(timeout):
			}
		}
	}()
}