import ( "github.com/BurntSushi/xgbutil/xutil" ) conn, err := xutil.NewConn() if err != nil { // Handle error } defer conn.Close()
import ( "github.com/BurntSushi/xgbutil" "github.com/BurntSushi/xgbutil/xinerama" ) // Get the current screen x, err := xgbutil.NewConn() if err != nil { // Handle error } screenIdx := x.XScreen() screen := x.Screen(screenIdx) // Get the Xinerama screen info xscreens, err := xinerama.PhysicalScreens(x) if err != nil || xscreens == nil || len(xscreens) == 0 { // Not using Xinerama, so just return the screen size width := screen.WidthInPixels height := screen.HeightInPixels } else { // Using Xinerama, so combine the screen sizes width := 0 height := 0 for _, xs := range xscreens { if xs.X+xs.Width > width { width = xs.X + xs.Width } if xs.Y+xs.Height > height { height = xs.Y + xs.Height } } }This example demonstrates how to query the screen dimensions using the Xinerama extension. The PhysicalScreens function is used to get the Xinerama screen info, which is then combined to get the total screen size. Overall, the github.com.burntsushi.xgbutil XUtil Conn package provides a convenient set of tools for working with X11 in Go. Its functions and utilities make it easy to create X11 applications that are robust and efficient.