summaryrefslogtreecommitdiff
path: root/showAll.go
blob: 3524db2ec8497663b7f2324db94470f736569b60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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]
				title := strings.Join(fields[7:], " ")

				fmt.Printf("Terminal Window Found:\n")
				fmt.Printf("  Title: %s\n", title)
				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)
	}
}