package main import ( "fmt" "github.com/BurntSushi/xgbutil/xprop" "github.com/BurntSushi/xgbutil/xwindow" "github.com/BurntSushi/xgbutil/xutil" ) func main() { X, err := xgbutil.NewConn() if err != nil { log.Fatal(err) } rootWindowID := xprop.RootWindowIdGet(X) fmt.Println(rootWindowID) }
package main import ( "github.com/BurntSushi/xgbutil/xgraphics" "github.com/BurntSushi/xgbutil/xwindow" "github.com/BurntSushi/xgbutil/xutil" "image/color" ) func main() { X, err := xgbutil.NewConn() if err != nil { log.Fatal(err) } rootWin, err := xwindow.Root(X) if err != nil { log.Fatal(err) } black := color.RGBA{0, 0, 0, 255} xgraphics.FillRectangle(X, black, rootWin.Id, 0, 0, 1920, 1080) xgraphics.Flush(X) }This example uses the xgraphics.FillRectangle function to set the background color of the root window to black. The xgraphics.Flush function is used to flush the changes to the X server. Overall, the github.com.burntsushi.xgbutil XUtil RootWin package provides a useful set of utilities for working with the root window of the X server in Go.