Skip to content

ConnorsApps/pipewire-monitor-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)
		}
	}
}