summaryrefslogtreecommitdiff
path: root/stuff.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-11-24 06:57:05 -0600
committerJeff Carr <[email protected]>2024-11-24 06:57:05 -0600
commitcfd6fdadd756edccd0115563d759e37306b57e9c (patch)
tree4c4e040ef66da9944c3e1b7a262e0f258668b329 /stuff.go
day 1v0.0.0
Diffstat (limited to 'stuff.go')
-rw-r--r--stuff.go69
1 files changed, 69 insertions, 0 deletions
diff --git a/stuff.go b/stuff.go
new file mode 100644
index 0000000..d3e5deb
--- /dev/null
+++ b/stuff.go
@@ -0,0 +1,69 @@
+package main
+
+import (
+ "fmt"
+ "os"
+ "os/exec"
+ "time"
+
+ "github.com/BurntSushi/xgb"
+ "github.com/BurntSushi/xgb/xproto"
+ "go.wit.com/log"
+)
+
+func main() {
+ conn, err := xgb.NewConn()
+ if err != nil {
+ fmt.Println("Failed to connect to X server:", err)
+ os.Exit(1)
+ }
+ defer conn.Close()
+
+ // Start the terminal (replace with your app)
+ go func() {
+ if err := exec.Command("mate-terminal", "--title", "Workspace1-Terminal").Start(); err != nil {
+ fmt.Println("Error starting terminal:", err)
+ }
+ }()
+
+ // Wait for the window to appear
+ time.Sleep(2 * time.Second)
+
+ // Get the root window
+ setup := xproto.Setup(conn)
+ root := setup.DefaultScreen(conn).Root
+
+ // List children windows
+ reply, err := xproto.QueryTree(conn, root).Reply()
+ if err != nil {
+ fmt.Println("Failed to query windows:", err)
+ os.Exit(1)
+ }
+
+ // Find the window with the specified title
+ var target xproto.Window
+ for _, child := range reply.Children {
+ nameReply, err := xproto.GetProperty(conn, false, child,
+ xproto.AtomWmName, xproto.AtomString, 0, (1<<32)-1).Reply()
+ if err != nil || len(nameReply.Value) == 0 {
+ continue
+ }
+
+ name := string(nameReply.Value)
+ log.Info("found name:", name)
+ if name == "Workspace1-Terminal" {
+ target = child
+ break
+ }
+ }
+
+ if target == 0 {
+ fmt.Println("Window not found.")
+ os.Exit(1)
+ }
+
+ // Move the window to workspace 1 and set its geometry
+ xproto.ConfigureWindow(conn, target, xproto.ConfigWindowX|xproto.ConfigWindowY|xproto.ConfigWindowWidth|xproto.ConfigWindowHeight,
+ []uint32{100, 100, 800, 600})
+ fmt.Println("Window moved and resized.")
+}