Skip to content

Latest commit

 

History

History
39 lines (32 loc) · 701 Bytes

README.md

File metadata and controls

39 lines (32 loc) · 701 Bytes

Pipewire Monitor Golang

A wrapper for watching Pipewire events using the CLI pw-dump

pw-dump ---monitor --no-colors

Example

import (
	"context"
	"fmt"

	pwmonitor "github.com/ConnorsApps/pipewire-monitor-go"
)

// Only watch for nodes or removal events
func filter(e *pwmonitor.Event) bool {
	return e.Type == pwmonitor.EventNode || e.IsRemovalEvent()
}

func main() {
	var (
		ctx        = context.Background()
		eventsChan = make(chan []*pwmonitor.Event)
	)
	go func() {
		panic(pwmonitor.Monitor(ctx, eventsChan, filter))
	}()

	for {
		events := <-eventsChan
		for _, e := range events {
			fmt.Println(e.Type, "id:", e.ID)
		}
	}
}