Skip to content

Commit 4b1279b

Browse files
committed
Refs #159, define path for default .Xauthority file, if env variable is not defined.
1 parent c6e2a47 commit 4b1279b

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/session_xorg.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ import (
55
"net"
66
"os"
77
"os/exec"
8+
"path/filepath"
89
"strconv"
910
"syscall"
1011
)
1112

13+
const defaultXauthorityPath = ".Xauthority"
14+
1215
// xorgSession defines structure for xorg
1316
type xorgSession struct {
1417
*commonSession
@@ -69,7 +72,12 @@ func (x *xorgSession) startCarrier() {
6972
}
7073
logPrint("Started Xorg")
7174

72-
if xorgConn, err := openXDisplay(x.auth.usr().getenv(envDisplay), x.auth.usr().getenv(envXauthority)); err != nil {
75+
xAuthorityPath := x.auth.usr().getenv(envXauthority)
76+
if xAuthorityPath == "" {
77+
xAuthorityPath = filepath.Join(x.auth.usr().homedir, defaultXauthorityPath)
78+
}
79+
80+
if xorgConn, err := openXDisplay(x.auth.usr().getenv(envDisplay), xAuthorityPath); err != nil {
7381
logPrintf("Could not open X Display: %v", err)
7482
handleStrErr("Could not open X Display.")
7583
} else {

src/x11.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func openXDisplay(dispName, xauthorityPath string) (net.Conn, error) {
2929
counter := 0
3030
deadline := time.Now().Add(30 * time.Second)
3131

32+
time.Sleep(50 * time.Millisecond)
3233
for time.Now().Before(deadline) {
3334
conn, err := net.DialTimeout("unix", socketPath, 200*time.Millisecond)
3435
if err == nil {
@@ -46,7 +47,7 @@ func openXDisplay(dispName, xauthorityPath string) (net.Conn, error) {
4647
if wait > maxWaitToOpenX11Display {
4748
wait = maxWaitToOpenX11Display
4849
}
49-
logPrintf("waiting for %s to try to open X11 display again", wait)
50+
logPrintf("X11 display open waiting for %s to try to again", wait)
5051
time.Sleep(wait)
5152
counter++
5253
}

0 commit comments

Comments
 (0)