diff options
author | Přemysl Janouch <p@janouch.name> | 2018-08-23 23:30:08 +0200 |
---|---|---|
committer | Přemysl Janouch <p@janouch.name> | 2018-09-02 18:25:36 +0200 |
commit | 9e070e964851544d0c2840e8d123a71c80772e80 (patch) | |
tree | 26e9abe6601d937cbdbafdb3c8f96ca144de8f64 | |
parent | 0c2853a8ae51367e03b727538d01b07642e276d7 (diff) | |
download | haven-9e070e964851544d0c2840e8d123a71c80772e80.tar.gz haven-9e070e964851544d0c2840e8d123a71c80772e80.tar.xz haven-9e070e964851544d0c2840e8d123a71c80772e80.zip |
xgb-monitors: add an experimental dumper
-rw-r--r-- | prototypes/xgb-monitors.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/prototypes/xgb-monitors.go b/prototypes/xgb-monitors.go new file mode 100644 index 0000000..5ce5af9 --- /dev/null +++ b/prototypes/xgb-monitors.go @@ -0,0 +1,40 @@ +package main + +import ( + "github.com/BurntSushi/xgb" + "github.com/BurntSushi/xgb/xproto" + "log" + + // Needs a patched local version with xcb-proto 1.12 and this fix: + // -size := xgb.Pad((8 + (24 + xgb.Pad((int(NOutput) * 4))))) + // +size := xgb.Pad((8 + (24 + xgb.Pad((int(Monitorinfo.NOutput) * 4))))) + "github.com/BurntSushi/xgb/randr" +) + +func main() { + X, err := xgb.NewConn() + if err != nil { + log.Fatalln(err) + } + + if err := randr.Init(X); err != nil { + log.Fatalln(err) + } + + setup := xproto.Setup(X) + screen := setup.DefaultScreen(X) + + ms, err := randr.GetMonitors(X, screen.Root, true /* GetActive */).Reply() + if err != nil { + log.Fatalln(err) + } + + for _, m := range ms.Monitors { + reply, err := xproto.GetAtomName(X, m.Name).Reply() + if err != nil { + log.Fatalln(err) + } + + log.Printf("Monitor %s %+v\n", reply.Name, m) + } +} |