@@ -81,11 +81,12 @@ func Run(opts ...command.Option[Options]) error {
8181 if err != nil {
8282 return err
8383 }
84- cfg .RootDir = filepath .Dir (path )
8584
8685 if cfg == nil {
8786 return fmt .Errorf ("cannot start profile: nil config" )
8887 }
88+
89+ cfg .RootDir = filepath .Dir (path )
8990 profile , ok := cfg .Profile (o .Profile )
9091 if ! ok {
9192 return fmt .Errorf ("cannot start profile: profile %q not found" , o .Profile )
@@ -336,6 +337,7 @@ func Start(runner string, profile *types.Profile, cfg *types.Config, interactive
336337 creds .CA , creds .ClientPEM , creds .ClientKeyPEM ,
337338 profile , strconv .Itoa (int (profile .Display )), interactive , cfg )
338339 if err != nil {
340+ slog .Warn ("failed to create display" , "error" , err )
339341 return err
340342 }
341343
@@ -412,12 +414,13 @@ func createMagicCookie(profile *types.Profile) error {
412414
413415 xauthority := os .Getenv ("XAUTHORITY" )
414416 if xauthority == "" {
415- return fmt . Errorf ( " XAUTHORITY not defined " )
417+ xauthority = os . ExpandEnv ( "${HOME}/. XAUTHORITY" )
416418 }
417419
418420 slog .Debug ("opening parent xauthority" , "path" , xauthority )
419421 parent , err := os .Open (xauthority )
420422 if err != nil {
423+ slog .Debug ("failed to open parent xauthority" , "error" , err )
421424 return err
422425 }
423426 defer parent .Close ()
@@ -470,6 +473,7 @@ func createNewDisplay(bin string, ca, cert, key []byte, profile *types.Profile,
470473 "-tst" ,
471474 "-nolisten" , "tcp" ,
472475 "-auth" , "/home/xorg-user/.Xserver" ,
476+ "-verbose" , "9" ,
473477 "--" ,
474478 strings .TrimPrefix (profile .WindowManager , "exec " )}
475479 }
@@ -549,7 +553,6 @@ func createNewDisplay(bin string, ca, cert, key []byte, profile *types.Profile,
549553 "--rm" ,
550554 // rely on currently set DISPLAY.
551555 "-e" , "DISPLAY" ,
552- "-e" , "XDG_SESSION_TYPE=X11" ,
553556 "-e" , "Q_MTLS_CA" ,
554557 "-e" , "Q_MTLS_CERT" ,
555558 "-e" , "Q_MTLS_KEY" ,
@@ -578,10 +581,20 @@ func createNewDisplay(bin string, ca, cert, key []byte, profile *types.Profile,
578581 }
579582
580583 // TODO: Investigate ways to avoid sharing /run/user/1000 on Wayland.
581- dockerArgs = append (dockerArgs , "-e XDG_RUNTIME_DIR" )
584+ dockerArgs = append (dockerArgs , "-e" , "XDG_RUNTIME_DIR" )
585+ dockerArgs = append (dockerArgs , "-e" , "XDG_BACKEND" )
586+ dockerArgs = append (dockerArgs , "-e" , "XDG_SEAT" )
587+ dockerArgs = append (dockerArgs , "-e" , "XDG_SESSION_TYPE" )
588+ dockerArgs = append (dockerArgs , "-e" , "XDG_SESSION_ID" )
589+ dockerArgs = append (dockerArgs , "-e" , "XDG_SESSION_CLASS" )
590+ dockerArgs = append (dockerArgs , "-e" , "XDG_SESSION_DESKTOP" )
591+ dockerArgs = append (dockerArgs , "-e" , "WAYLAND_DISPLAY" )
592+ dockerArgs = append (dockerArgs , "-e" , "HYPRLAND_INSTANCE_SIGNATURE" )
582593 dockerArgs = append (dockerArgs , "-v=" + xdgRuntimeDir + ":/run/user/1000" )
594+ } else {
595+ dockerArgs = append (dockerArgs , "-e" , "XDG_SESSION_TYPE=X11" )
583596 }
584- if profile .HostAccess . Gpus != "" {
597+ if profile .Gpus != "" {
585598 if gpus , ok := gpu .Supported (profile .Runner ); ok {
586599 dockerArgs = append (dockerArgs , gpus )
587600 }
@@ -623,6 +636,7 @@ func createNewDisplay(bin string, ca, cert, key []byte, profile *types.Profile,
623636
624637 paths = append (paths , fmt .Sprintf ("-v=%s:/dev/shm" , filepath .Join (userDir , "shm" )))
625638 if profile .Dbus {
639+ paths = append (paths , "-v=/run/dbus/system_bus_socket:/run/dbus/system_bus_socket" )
626640 paths = append (paths , "-v=/etc/machine-id:/etc/machine-id:ro" )
627641 } else {
628642 paths = append (paths , fmt .Sprintf ("-v=%s:/run/user/1000" , userDir ))
@@ -657,6 +671,8 @@ func createNewDisplay(bin string, ca, cert, key []byte, profile *types.Profile,
657671
658672 slog .Debug ("exec: " + bin , "args" , dockerArgs )
659673 cmd := execabs .Command (bin , dockerArgs ... )
674+ cmd .Env = append (cmd .Env , os .Environ ()... )
675+
660676 cmd .Env = append (os .Environ (), "Q_MTLS_CA=" + string (ca ))
661677 cmd .Env = append (cmd .Env , "Q_MTLS_CERT=" + string (cert ))
662678 cmd .Env = append (cmd .Env , "Q_MTLS_KEY=" + string (key ))
0 commit comments