Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle missing patch version by making it optional in regex matching. #417

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func serverInfo(paClient *pulseaudio.Client) (audioserverinfo, error) {
} else {
servername = "PulseAudio"
servertype = servertype_pulse
versionRegex = regexp.MustCompile(`.*?(\d+)\.(\d+)\.(\d+).*?`)
versionRegex = regexp.MustCompile(`.*?(\d+)\.(\d+)\.?(\d+)?.*?`)
versionString = info.PackageVersion
log.Printf("Detected PulseAudio\n")
}
Expand All @@ -264,6 +264,11 @@ func serverInfo(paClient *pulseaudio.Client) (audioserverinfo, error) {
log.Printf("couldn't parse server version, regexp didn't match version: %s\n", versionString)
return audioserverinfo{servertype: servertype}, nil
}
// the server version did not match the standard `major.minor.patch` pattern
// setting the patch version to default 0
if res[3] == "" {
res[3] = "0"
}
major, err = strconv.Atoi(res[1])
if err != nil {
return audioserverinfo{servertype: servertype}, err
Expand Down Expand Up @@ -330,7 +335,7 @@ func getDefaultSinkID(client *pulseaudio.Client) (string, error) {
return server.DefaultSink, nil
}

//this is disgusting
// this is disgusting
func fixWindowClass() {
xu, err := xgbutil.NewConn()
defer xu.Conn().Close()
Expand Down
Loading