mirror of
https://codeberg.org/scip/swayipc.git
synced 2025-12-16 20:20:56 +01:00
41 lines
504 B
Go
41 lines
504 B
Go
|
|
package main
|
||
|
|
|
||
|
|
/*
|
||
|
|
Retrieve a list of running bars
|
||
|
|
*/
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"log"
|
||
|
|
|
||
|
|
"github.com/alecthomas/repr"
|
||
|
|
"github.com/tlinden/i3ipc"
|
||
|
|
)
|
||
|
|
|
||
|
|
func main() {
|
||
|
|
ipc := i3ipc.NewI3ipc()
|
||
|
|
|
||
|
|
err := ipc.Connect()
|
||
|
|
if err != nil {
|
||
|
|
log.Fatal(err)
|
||
|
|
}
|
||
|
|
|
||
|
|
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)
|
||
|
|
}
|
||
|
|
}
|