Files
swayipc/_examples/find_focused_window/main.go

31 lines
460 B
Go
Raw Normal View History

2025-08-14 14:16:17 +02:00
package main
import (
"fmt"
"log"
2025-08-16 19:50:30 +02:00
"github.com/tlinden/swayipc"
2025-08-14 14:16:17 +02:00
)
func main() {
2025-08-16 19:50:30 +02:00
ipc := swayipc.NewSwayIPC()
2025-08-14 14:16:17 +02:00
err := ipc.Connect()
if err != nil {
log.Fatal(err)
}
defer ipc.Close()
2025-08-14 14:16:17 +02:00
tree, err := ipc.GetTree()
if err != nil {
log.Fatal(err)
}
focused := tree.FindFocused()
if focused != nil {
fmt.Printf("focused node: %s\n id: %d\n Geometry: %dx%d\n",
focused.Name, focused.Id, focused.Geometry.Width, focused.Geometry.Height)
}
}