mirror of
https://codeberg.org/scip/swayipc.git
synced 2025-12-16 20:20:56 +01:00
implemented more stuff along with samples
This commit is contained in:
29
_examples/find_focused_window/main.go
Normal file
29
_examples/find_focused_window/main.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/tlinden/i3ipc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ipc := i3ipc.NewI3ipc("SWAYSOCK")
|
||||
|
||||
err := ipc.Connect()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user