Files
swayipc/_examples/get_bars/main.go
2025-11-10 20:59:46 +01:00

42 lines
531 B
Go

package main
/*
Retrieve a list of running bars
*/
import (
"fmt"
"log"
"github.com/alecthomas/repr"
"codeberg.org/scip/swayipc/v1"
)
func main() {
ipc := swayipc.NewSwayIPC()
err := ipc.Connect()
if err != nil {
log.Fatal(err)
}
defer ipc.Close()
bars, err := ipc.GetBars()
if err != nil {
log.Fatal(err)
}
fmt.Println("Current bars:")
repr.Println(bars)
if len(bars) > 0 {
fmt.Println("First bar:")
bar, err := ipc.GetBar(bars[0])
if err != nil {
log.Fatal(err)
}
repr.Println(bar)
}
}