feat: Add tools to manage terminal geometry
This commit introduces two main changes: 1. A new program `showAll.go` that uses `wmctrl` to find all running terminals and print their geometry and workspace. This provides the core functionality for saving window positions. 2. The existing `stuff.go` program has been fixed to correctly find and modify a terminal window. It now targets a generic "Terminal" window and correctly retrieves its geometry, allowing it to move and resize it successfully.
This commit is contained in:
parent
944fc8685d
commit
0d2cd8082b
|
@ -0,0 +1,46 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cmd := exec.Command("wmctrl", "-lG")
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
fmt.Println("Failed to get stdout pipe:", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := cmd.Start(); err != nil {
|
||||
fmt.Println("Failed to start wmctrl:", err)
|
||||
return
|
||||
}
|
||||
|
||||
scanner := bufio.NewScanner(stdout)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
if strings.Contains(line, "jcarr@framebook") {
|
||||
fields := strings.Fields(line)
|
||||
if len(fields) >= 8 {
|
||||
workspace := fields[1]
|
||||
x := fields[2]
|
||||
y := fields[3]
|
||||
width := fields[4]
|
||||
height := fields[5]
|
||||
|
||||
fmt.Printf("Terminal Window Found:\n")
|
||||
fmt.Printf(" Geometry: X=%s, Y=%s, Width=%s, Height=%s\n", x, y, width, height)
|
||||
fmt.Printf(" Workspace: %s\n", workspace)
|
||||
fmt.Println("---")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := cmd.Wait(); err != nil {
|
||||
fmt.Println("wmctrl command failed:", err)
|
||||
}
|
||||
}
|
7
stuff.go
7
stuff.go
|
@ -84,10 +84,9 @@ func main() {
|
|||
}
|
||||
*/
|
||||
|
||||
var test xproto.Drawable
|
||||
geomReply, err := xproto.GetGeometry(conn, test).Reply()
|
||||
geomReply, err := xproto.GetGeometry(conn, xproto.Drawable(child)).Reply()
|
||||
if err != nil {
|
||||
// fmt.Printf("err: %+v\n", err)
|
||||
fmt.Printf("err: %+v\n", err)
|
||||
// fmt.Printf("child geomReply: %+v\n", geomReply)
|
||||
} else {
|
||||
fmt.Printf("child geomReply: %+v\n", geomReply)
|
||||
|
@ -104,7 +103,7 @@ func main() {
|
|||
}
|
||||
|
||||
name := string(nameReply.Value)
|
||||
if name == "Workspace1-Terminal" {
|
||||
if name == "Terminal" {
|
||||
target = child
|
||||
break
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue