Skip to content

Commit

Permalink
add monitor and monitored to source status
Browse files Browse the repository at this point in the history
  • Loading branch information
undg committed Feb 11, 2025
1 parent ab4f669 commit a599e99
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
17 changes: 11 additions & 6 deletions pactl/pactl.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,24 @@ func parseSources(output string) Source {
descRe, _ := regexp.Compile(`Description: (.+)`)
volumeRe, _ := regexp.Compile(`Volume: .+?(\d+)%`)
muteRe, _ := regexp.Compile(`Mute: (yes|no)`)
monitorRe, _ := regexp.Compile(`Monitor of Sink: (.+)`) // n/a or name of the Sink

id, _ := strconv.Atoi(idRe.FindStringSubmatch(output)[1])
name := nameRe.FindStringSubmatch(output)[1]
desc := descRe.FindStringSubmatch(output)[1]
volume, _ := strconv.Atoi(volumeRe.FindStringSubmatch(output)[1])
mute := muteRe.FindStringSubmatch(output)[1] == "yes"
muted := muteRe.FindStringSubmatch(output)[1] == "yes"
monitored := monitorRe.FindStringSubmatch(output)[1] == "n/a"
monitor := monitorRe.FindStringSubmatch(output)[1]

return Source{
ID: id,
Name: name,
Label: desc,
Volume: volume,
Muted: mute,
ID: id,
Name: name,
Label: desc,
Volume: volume,
Muted: muted,
Monitor: monitor,
Monitored: monitored,
}
}

Expand Down
12 changes: 7 additions & 5 deletions pactl/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ type Output struct {
}

type Source struct {
ID int `json:"id" doc:"The id of the source. Same as name"`
Name string `json:"name" doc:"The name of the source. Same as id"`
Label string `json:"label" doc:"Human-readable label for the source"`
Volume int `json:"volume" doc:"Current volume level of the source"`
Muted bool `json:"muted" doc:"Whether the source is muted"`
ID int `json:"id" doc:"Unique numeric identifier of the source"`
Name string `json:"name" doc:"Unique string identifier of the source"`
Label string `json:"label" doc:"Human-readable label for the source"`
Volume int `json:"volume" doc:"Current volume level of the source"`
Muted bool `json:"muted" doc:"Whether the source is muted"`
Monitor string `json:"monitor" doc:"Name of monitor source capturing this source's output"`
Monitored bool `json:"monitored" doc:"Whether source is being monitored"`
}

type App struct {
Expand Down

0 comments on commit a599e99

Please sign in to comment.