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

Use the default fallback path for the session bus #385

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 3 additions & 15 deletions conn_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package dbus

import (
"bytes"
"errors"
"fmt"
"io/ioutil"
Expand All @@ -15,26 +14,15 @@
"strings"
)

var execCommand = exec.Command

Check failure on line 17 in conn_other.go

View workflow job for this annotation

GitHub Actions / lint

var `execCommand` is unused (unused)

func getSessionBusPlatformAddress() (string, error) {
cmd := execCommand("dbus-launch")
b, err := cmd.CombinedOutput()
if err != nil {
return "", err
}

i := bytes.IndexByte(b, '=')
j := bytes.IndexByte(b, '\n')

if i == -1 || j == -1 || i > j {
rundir, ok := os.LookupEnv("XDG_RUNTIME_DIR")
if !ok {
return "", errors.New("dbus: couldn't determine address of session bus")
}

env, addr := string(b[0:i]), string(b[i+1:j])
os.Setenv(env, addr)

return addr, nil
return path.Join(rundir, "bus"), nil
}

// tryDiscoverDbusSessionBusAddress tries to discover an existing dbus session
Expand Down
Loading