Skip to content

Instantly share code, notes, and snippets.

@tdcosta100
Last active December 21, 2024 15:44
Show Gist options
  • Save tdcosta100/e28636c216515ca88d1f2e7a2e188912 to your computer and use it in GitHub Desktop.
Save tdcosta100/e28636c216515ca88d1f2e7a2e188912 to your computer and use it in GitHub Desktop.
A tutorial to use GUI in WSL2/WSLg replacing original Xorg by Xwayland, allowing WSL to work like native Linux, including login screen

Full desktop shell in WSL2 using WSLg (XWayland)

Note

If you want to use Wayland in WSLg in a simpler setup, you can try the WSLg (Wayland) tutorial.

In this tutorial, we will setup GUI in WSL2. No additional software outside WSL (like VcXsrv or GWSL) is required. You will find this tutorial very similar to the one that replaces Xorg with Xvnc. Indeed, it's pretty much the same tutorial, with some few changes.

The key component we need to install is the desktop metapackage you want (GNOME, KDE, Xfce, Budgie, etc), and after that, replace the default Xorg by a script that calls Xwayland instead.

For this setup, I will use Ubuntu 24.04, and install GNOME Desktop. Unfortunately older versions of Ubuntu lack some fundamental things, so we cannot reproduce it in older versions (at least not fully). Since the key components aren't bound to Ubuntu or GNOME, you can use your favorite distro and GUI. Check the Sample screenshots section for examples.

So let's go. First, we need a working WSL2 installation.

Warning

WSLg may not work as expected, since Wayland sockets are disabled for everyone, and not every app can handle this. But if you want to use Wayland apps natively, you can use the command export XDG_RUNTIME_DIR=$HOME/runtime-dir and then start your WSLg app.

Before going to real business, let's make sure we are updated.

sudo apt update
sudo apt upgrade

You also need to make sure /etc/wsl.conf have the following lines:

[boot]
systemd=true

If not, create/edit this file, add these lines and restart WSL (for example, using wsl.exe --shutdown, then reopening the distro terminal).

Now we are ready to go.

Installing components

Installing GUI

  1. First you select your favorite desktop environment metapackage. Here is a list of the most common metapackages:

    DistroDesktop EnvironmentMetapackage
    UbuntuBudgieubuntu-budgie-desktop (currently very buggy, I don't recommend using it)
    GNOMEubuntu-desktop
    KDEkubuntu-desktop
    Kylinubuntukylin-desktop
    LXDElubuntu-desktop
    MATEubuntu-mate-desktop
    Studioubuntustudio-desktop
    Unityubuntu-unity-desktop
    Xfcexubuntu-desktop
    Ubuntu/DebianCinnamontask-cinnamon-desktop
    GNOMEtask-gnome-desktop
    GNOME Flashbacktask-gnome-flashback-desktop
    KDE Plasmatask-kde-desktop
    LXDEtask-lxde-desktop
    LXQttask-lxqt-desktop
    MATEtask-mate-desktop
    Xfcetask-xfce-desktop
  2. Once you have chosen the metapackage, let's install it. For example, if you choose ubuntu-desktop, the command will be:

    sudo apt install ubuntu-desktop xwayland
    

    This will install the ubuntu-desktop and xwayland (if not already included as dependency for your metapackage). The installation will take a while, so be patient.

  3. If in Ubuntu, you may want to install snap-store. If you don't need it, you can skip this step:

    sudo snap install snap-store
    

Configuring the environment

If you are using Debian, you need to configure the locale (this is not needed in Ubuntu):

echo "LANG=en_US.UTF-8" | sudo tee -a /etc/default/locale

Create and modify services

  1. Now we have everything installed, we need to fix the directory /tmp/.X11-unix/, because it's mounted as read-only by default. We will create a new systemd unit:

    sudo systemctl edit --full --force wslg-fix.service
    
  2. Paste the code below in the editor:

    [Service]
    Type=oneshot
    ExecStart=-/usr/bin/umount /tmp/.X11-unix
    ExecStart=/usr/bin/rm -rf /tmp/.X11-unix
    ExecStart=/usr/bin/mkdir /tmp/.X11-unix
    ExecStart=/usr/bin/chmod 1777 /tmp/.X11-unix
    ExecStart=/usr/bin/ln -s /mnt/wslg/.X11-unix/X0 /tmp/.X11-unix/X0
    ExecStart=/usr/bin/chmod 0777 /mnt/wslg/runtime-dir
    ExecStart=/usr/bin/chmod 0666 /mnt/wslg/runtime-dir/wayland-0.lock
    
    [Install]
    WantedBy=multi-user.target
    
  3. Exit the editor saving the changes to the file.

  4. Let's enable wslg-fix.service:

    sudo systemctl enable wslg-fix.service
    
  5. We also need to remove all references to Wayland, because if not, some apps (gnome-terminal, for example) will open outside the desktop shell. We will edit the user-runtime-dir@.service service:

    sudo systemctl edit user-runtime-dir@.service
    
  6. Paste the code below in the editor:

    [Service]
    ExecStartPost=-/usr/bin/rm -f /run/user/%i/wayland-0 /run/user/%i/wayland-0.lock
    

Warning

Please read the editor instructions about the correct place to position the text cursor before pasting. If you paste the code in the wrong place, it will be discarded.

  1. Exit the editor saving the changes to the file.

  2. Now we will change the default startup target, because if not, a shell window will appear everytime you start your distro (for example, opening a Terminal of your distro in Windows).

    sudo systemctl set-default multi-user.target
    

Replacing default Xorg by XWayland

By default, the display manager call multiple Xorg instances, one for each user session, including the login screen, provided by GDM (if you are using the GDM as your display manager, of course). So we will replace Xorg script by a new version which calls Xwayland instead the classic Xorg. This is the real magic we are trying to do.

  1. First, let's backup the original Xorg script.

    sudo mv /usr/bin/Xorg /usr/bin/Xorg.original
    
  2. Then, we create a new Xorg script.

    sudo nano /usr/bin/Xorg.Xwayland
    
  3. Paste the code below in the editor:

    #!/bin/bash
    for arg do
      shift
      case $arg in
        # Xwayland doesn't support vtxx argument. So we convert to ttyxx instead
        vt*)
          set -- "$@" "${arg//vt/tty}"
          ;;
        # -keeptty is not supported at all by Xwayland
        -keeptty)
          ;;
        # -novtswitch is not supported at all by Xwayland
        -novtswitch)
          ;;
        # other arguments are kept intact
        *)
          set -- "$@" "$arg"
          ;;
      esac
    done
    
    # Check if the runtime dir is present, and create it if not
    if [ ! -d $HOME/runtime-dir ]
    then
     mkdir $HOME/runtime-dir
     ln -s /mnt/wslg/runtime-dir/wayland-0 /mnt/wslg/runtime-dir/wayland-0.lock $HOME/runtime-dir/
    fi
    
    # Point the XDG_RUNTIME_DIR variable to $HOME/runtime-dir
    export XDG_RUNTIME_DIR=$HOME/runtime-dir
    
    # Find an available display number
    for displayNumber in $(seq 1 100)
    do
      [ ! -e /tmp/.X11-unix/X$displayNumber ] && break
    done
    
    # Here you can change or add options to fit your needs
    command=("/usr/bin/Xwayland" ":${displayNumber}" "-geometry" "1920x1080" "-fullscreen" "$@")
    
    systemd-cat -t /usr/bin/Xorg echo "Starting Xwayland:" "${command[@]}"
    
    exec "${command[@]}"
    

    Please note the resolution of the virtual screen. You can change that to fit your needs (1366x768, 3840x2160, etc).

  4. Exit the editor saving the changes.

  5. Finally, we set the correct permissions for the file and create a link to it:

    sudo chmod 0755 /usr/bin/Xorg.Xwayland
    sudo ln -sf Xorg.Xwayland /usr/bin/Xorg
    

Warning

Sometimes, system updates replace Xorg link with the original version. Just repeat this step if this happens, and Xwayland will work again as Xorg replacement.

Configuring the monitor resolution under GDM and GNOME

Currently, one of the annoying things is the resolution of Xwayland. Even with the -geometry switch, GDM and GNOME don't not respect it. Fortunately, this can be overriden by creating a monitors.xml file. Let's do it then.

  1. First, we create it in the current user directory:

    mkdir ~/.config
    nano ~/.config/monitors.xml
    
  2. Paste the code below in the editor (here it is configured for a 1920x1080 resolution, so change it to reflect your resolution if necessary):

    <monitors version="2">
      <configuration>
        <logicalmonitor>
          <x>0</x>
          <y>0</y>
          <scale>1</scale>
          <primary>yes</primary>
          <monitor>
            <monitorspec>
              <connector>XWAYLAND0</connector>
              <vendor>unknown</vendor>
              <product>unknown</product>
              <serial>unknown</serial>
            </monitorspec>
            <mode>
              <width>1920</width>
              <height>1080</height>
              <rate>59.963</rate>
            </mode>
          </monitor>
        </logicalmonitor>
      </configuration>
    </monitors>
  3. Exit the editor saving the changes to the file.

  4. Now let's copy this file to GDM's home directory:

    sudo mkdir /var/lib/gdm3/.config
    sudo cp ~/.config/monitors.xml /var/lib/gdm3/.config/
    
  5. Finally, we set the correct permissions to the monitors.xml of GDM user:

    sudo chown -R gdm:gdm /var/lib/gdm3/.config/
    
  6. Restart WSL using wsl.exe --shutdown, then reopen your distro terminal.

Running your distro with GUI enabled

Now you have everything ready to start. Just do the following command:

sudo systemctl start graphical.target

After a while (usually a few seconds, but it can take more if you don't have a SSD), the login screen must appear.

After logging in, the logged user's desktop must appear. When you log out, the screen will show the login interface again. This applies to GDM (which is the case if you installed Ubuntu Desktop). In GDM, you can change this behavior changing the configuration file like this:

  1. sudo nano /etc/gdm3/custom.conf

  2. Uncomment and edit the following lines:

     AutomaticLoginEnable=true
     AutomaticLogin=[your username without the brackets]
    

Shutting down

One important thing is: once you start your WSL instance, you cannot just stop it. You must perform a standard Linux shutdown. You can do one of the alternatives below:

  • Power off option on GUI menu
  • sudo poweroff

After doing that, you can safely shut down your WSL instance, either by wsl.exe --terminate or wsl.exe --shutdown. Not doing the shutdown process may cause damage to your WSL instance. So be careful.

Troubleshooting

  1. If it doesn't work at first, try to check your journalctl logs:

    journalctl -b -t /usr/lib/gdm3/gdm-x-session -t /usr/bin/Xorg --no-pager
    

    If you are using Debian, then the command is:

    journalctl -b -t /usr/libexec/gdm-x-session -t /usr/bin/Xorg --no-pager
    

    In the output, you must see what command line was generated for Xwayland, and which error messages appear. Of course, even if it works correctly, you can check the logs just to see what is happening, or for debugging.

  2. You must check if the custom Xorg script was not replaced by the default version of it. If it was the case, just repeat the steps of Replacing default Xorg by Xwayland section.

  3. Check if Xorg is your default display server, not Xephyr or Wayland. If it's not, you must change it to have Xorg as your default display server.

  4. If you are using LightDM, you also need to check logs at /var/log/lightdm (you will need to use sudo to cat files in that directory). The Xwayland output will be in the file /var/log/lightdm/x-0.log.

  5. If it still doesn't work, you can try to restart WSL with wsl.exe --shutdown (don't forget to save everything that is unsaved before, because WSL will shut down completely), then open your distro terminal again and repeat the steps of section Running your distro with GUI enabled.

Sample screenshots

GDM

GDM

LightDM (Kubuntu)

LightDM

GNOME

GNOME

KDE (Kubuntu)

KDE

LXDE (Lubuntu)

LXDE

Xfce (Xubuntu)

Xfce

Contributors

Thanks to this guys, whose feedback made this tutorial reach the current level of quality and completeness (and it will be more and more complete as more feedback is given).

@marrocksd
Copy link

marrocksd commented Nov 14, 2024

here it is
Right click -> New shortcut, use this command

wsl.exe -e bash -c "echo 'sudo_password' | sudo -S systemctl start graphical.target ; exec bash"

@FabryB
Copy link

FabryB commented Nov 16, 2024

Hi, works perfectly when launched manually in console with
sudo systemctl start graphical.target
but I'm unable to autorun the graphical version: tried to run
sudo systemctl set-default graphical.target
but then on reboot it shows the "Oh no! Something has gone wrong." white screen

is it possible to autostart the graphical target on wsl start?

@tdcosta100
Copy link
Author

tdcosta100 commented Nov 16, 2024

It works correctly here. Did you do a wsl --shutdown before starting it again? Because WSL distros don't reboot well yet.

@marrocksd
Copy link

hi. is it posible to make clipboard work? i try to change wslg.rdp but with no effect. same with multi monitors but its less troubling

Hy, @loadlost! Did you try the clipboard-sync? I tried here and it worked like a charm. Please tell me if it works for you. I'm considering putting it in the tutorial.

confirm this one works like a charm

@rye2020
Copy link

rye2020 commented Nov 17, 2024

How to enable sound? For example, rhythmbox has no sound. And Gnome settings shows "Dummy Output" for an output device.

@tdcosta100
Copy link
Author

Try this:

Thank you! Well, the problem is: in the $XDG_RUNTIME_DIR/pulse directory, there are two files, native and pid. These files are the same we encounter in /mnt/wslg/runtime-dir/pulse, but because of pulseaudio/pipewire, they are overwrited, so the audio link between the distro and the WSLg is broken. We have to prevent this to hear any audio.

You can try masking the pipewire-pulse service and socket:

systemctl --user mask pipewire-pulse.service
systemctl --user mask pipewire-pulse.socket

And before starting the graphical.target:

mkdir $XDG_RUNTIME_DIR/pulse
ln -s /mnt/wslg/runtime-dir/pulse/* $XDG_RUNTIME_DIR/pulse/

@rye2020
Copy link

rye2020 commented Nov 20, 2024

this did not work. See below:
jrm@LY7i:$ systemctl status pipewire-pulse
Unit pipewire-pulse.service could not be found.
jrm@LY7i:
$ mkdir $XDG_RUNTIME_DIR/pulse
mkdir: cannot create directory ‘/run/user/1000//pulse’: File exists
jrm@LY7i:~$ ln -s /mnt/wslg/runtime-dir/pulse/* $XDG_RUNTIME_DIR/pulse/
ln: failed to create symbolic link '/run/user/1000//pulse/native': File exists
ln: failed to create symbolic link '/run/user/1000//pulse/pid': File exists

@tdcosta100
Copy link
Author

tdcosta100 commented Nov 20, 2024

To see the status of pipewire-pulse.service, you need to use with --user, because is a user service, not a system service:

systemctl status --user pipewire-pulse

Of course pulse directory exists, because pipewire-pulse.service is active.

@rye2020
Copy link

rye2020 commented Nov 21, 2024

I should have known better -- need to restart Ubuntu after masking pipewire-pulse. It works perfectly. Thanks for the help. Much appreciated.

@GalaticStryder
Copy link

@tdcosta100 Saudações meu amigo, obrigado pelo script, estou usando ele no Fedora Remix WSL e funcionou praticamente tudo, porém, pelo comando do Xwayland eu só consigo uma tela preta aqui, o comando que funcionou foi o starplasma no Fedora e por padrão já tá no Wayland. Meu problema é a resolução, eu não consigo setar a resolução, quando o plasma abre ele mostra que só tem a opção de 1024x768 e nada mais. Só que o meu xrandr mostra todas as opções inclusive a 1080p. Diferente do jeito que o Ubuntu faz através do wrapper, o Fedora aparentemente usa o startplasma que é binário, não tem como fazer aquele lance de criar uma versão alternativa e tal. Teria que ter um jeito de passar pro startplasma a resolução como parâmetro ou investigar pq o xWayland não tá conseguindo ver todas as opções do xrandr.

@crramirez
Copy link

@GalaticStryder Writing in english will allow everyone here to understand without using a translator, not only the author.

In the case of Fedora Remix, change the resolution inside the desktop environment directly, the window will be adjusted. I can test again with plasma, but the last time I tested I could change it.

@GalaticStryder
Copy link

GalaticStryder commented Nov 27, 2024

@crramirez Thanks for input, I'll switch to English in this case. My current issue is that I'm only able to have my plasma interface to work by running startplasma (which is on pure wayland). It launches by default on 1024x768 resolution, and it's the only one option inside the plasma display settings. Using sudo systemctl start graphical.target doesn't do anything and /usr/bin/Xwayland" ":1" "-geometry" "1920x1080" "-fullscreen" just ends on a black screen for me.

@tdcosta100
Copy link
Author

@GalaticStryder muito obrigado! Tem uma versão em português do tutorial, lá você consegue perguntar em português mesmo. O resto da mensagem será em inglês.

Even with a binary file, you can make a wrapper, you just need to rename the original file to other thing, for example mv startplasma startplasma.original. Then you can write a script to adjust the command line parameters and call the original file in the end.

@GalaticStryder
Copy link

@tdcosta100 Yeah, I only need to know which parameters that command runs and how to pass them. I have done the sddm monitor config already and it's fullscrren but not when launching the instance from my terminal.

@crramirez
Copy link

@GalaticStryder Try to run: ln -sf /mnt/wslg/runtime-dir/wayland-0 /run/user/1000/wayland-0 before the Xwayland command. And remember the & WAYLAND_DISPLAY= DISPLAY=:1 after the Xwayland

@GalaticStryder
Copy link

@crramirez I've tried the following script based off the one from @tdcosta100 and your inputs.

#!/bin/bash
#
#
#

# Check if the runtime dir is present, and create it if not
if [ ! -d $HOME/runtime-dir ]
then
 mkdir $HOME/runtime-dir
 ln -s /mnt/wslg/runtime-dir/wayland-0 /mnt/wslg/runtime-dir/wayland-0.lock $HOME/runtime-dir/
fi

# Point the XDG_RUNTIME_DIR variable to $HOME/runtime-dir
export XDG_RUNTIME_DIR=$HOME/runtime-dir

# Find an available display number
for displayNumber in $(seq 1 100)
do
  [ ! -e /tmp/.X11-unix/X$displayNumber ] && break
done

sudo ln -sf /mnt/wslg/runtime-dir/wayland-0 /run/user/1000/wayland-0

# Here you can change or add options to fit your needs
command=("/usr/bin/Xwayland" ":${displayNumber}" "-geometry" "1920x1080" "-fullscreen" "-glamor" "off" ttyxx "$@")

systemd-cat -t /usr/bin/Xwayland echo "Starting Xwayland:" "${command[@]}"

exec "${command[@]}"

But still having only a blackscreen at the end. So far only the startplasma itself seems to do the job but with the wrong resolution.

@tdcosta100
Copy link
Author

@GalaticStryder you need to track where startplasma is called, and then change it, because it doesn't make difference if you are trying XWayland and the Fedora is trying to use Wayland instead.

@GalaticStryder
Copy link

@tdcosta100 Got it to work after installing some missing X11 packages for plasma, then I could get to the GUI with startplasma-x11. Now the only bug so far is that the plasmashell and other launched apps get separed across windows activities, like orphaned windows instead of launching inside the main screen. If there's any advice on solving that it would be awesome.

@JohnHolmesTW
Copy link

After installing a clean copy of Ubuntu (which is now 24.04.01) on a Dell Inspiron 16 Plus 7640 laptop (win11) which has an Nvidia 4060 GPU in it. I launch the desktop and I get a blank screen with the cursor and nothing else? I can tell the login box is there sometimes if I click around and even type in my password to get to a blank desktop with just a "Home" icon on it.

If I edit the /etc/gdm3/custom.conf file to auto login then It is definitely on the desktop because just the one 'Home' icon appears which I can move around but the rest of the desktop is still black. In fact, when I move the icon, you can briefly see a light blue square underneath the icon!?

image

I thought this may be due to it being 24.04.01 so I reverted back to 24.04 but that is the same. I also tried KDE and SDDM as desktop managers and they do the same, you get a cursor and a blank screen.

Any suggestions? I've been at this for about 8 hours and can't see where I'm going wrong short of trying on a different PC.

Running : " journalctl -b -t /usr/lib/gdm3/gdm-x-session -t /usr/bin/Xorg --no-pager " reports:
Nov 29 20:21:07 DEV-LAPTOP-JH /usr/bin/Xorg[924]: Starting Xwayland: /usr/bin/Xwayland :1 -geometry 1920x1080 -fullscreen tty1 -displayfd 3 -auth /run/user/121/gdm/Xauthority -nolisten tcp -background none -noreset -verbose 3

Running : " systemctl status display-manager.service " reports:
● gdm.service - GNOME Display Manager
Loaded: loaded (/usr/lib/systemd/system/gdm.service; static)
Active: active (running) since Fri 2024-11-29 20:43:43 GMT; 2min 0s ago
Process: 743 ExecStartPre=/usr/share/gdm/generate-config (code=exited, status=0/SUCCESS)
Main PID: 764 (gdm3)
Tasks: 4 (limit: 76501)
Memory: 4.5M ()
CGroup: /system.slice/gdm.service
└─764 /usr/sbin/gdm3

Nov 29 20:43:43 DEV-LAPTOP-JH systemd[1]: Starting gdm.service - GNOME Display Manager...
Nov 29 20:43:43 DEV-LAPTOP-JH systemd[1]: Started gdm.service - GNOME Display Manager.
Nov 29 20:43:43 DEV-LAPTOP-JH gdm-autologin][774]: gkr-pam: no password is available for user
Nov 29 20:43:43 DEV-LAPTOP-JH gdm-autologin][774]: pam_unix(gdm-autologin:session): session opened for user dev(uid=1000) by dev(uid=0)
Nov 29 20:43:43 DEV-LAPTOP-JH gdm-autologin][774]: gkr-pam: couldn't unlock the login keyring.
Nov 29 20:43:44 DEV-LAPTOP-JH gdm3[764]: Gdm: GdmDisplay: Session never registered, failing
Nov 29 20:43:44 DEV-LAPTOP-JH gdm-autologin][984]: gkr-pam: no password is available for user
Nov 29 20:43:44 DEV-LAPTOP-JH gdm-autologin][984]: pam_unix(gdm-autologin:session): session opened for user dev(uid=1000) by dev(uid=0)
Nov 29 20:43:44 DEV-LAPTOP-JH gdm-autologin][984]: gkr-pam: couldn't unlock the login keyring.

The errors about "no password is available" is because the desktop islocking and then I'm clicking around again trying to get back in.

Please help :)

@tdcosta100
Copy link
Author

tdcosta100 commented Nov 30, 2024

This is very strange. I will try to reproduce your problem, but meanwhile, did you update your display drivers? And maybe a wsl --update command will be interesting too if not done before.

Edit: yeah, I did a fresh install of Ubuntu 24.04.1, and everything went well, so there's a very high chance of your graphic drivers are malfunctioning.

It's important to say that despite you having a nice discrete GPU, WSL uses the default one, which probably is the integrated one. To change this behavior, you must set the MESA_D3D12_DEFAULT_ADAPTER_NAME variable system-wide (see here).

Maybe changing the adapter to the discrete one will make everything work as intended.

@destaa
Copy link

destaa commented Dec 2, 2024

I got converter from ubuntu 22.04 WSL to PopOS here, with GWSL from microsoft store.
I have followed the instruction from there but zero result.
what I want to achieve is to display full PopOS desktop with WSL, either it's WSL2 or GWSL or WSLg.

can you modify that converter according to your method to display PopOS with WSLg (XWayland)?
because I followed your instruction, and I succeded flawlessly. but I don't like ubuntu desktop.
I would be appreciate that.

@JohnHolmesTW
Copy link

@tdcosta100 Thanks for the help, I found the issue following your trail.

I updated the graphics drivers and also checked the wsl --update but that was already up to date. I then tried the MESA_D3D12_DEFAULT_ADAPTER_NAME settings and did find that when I run the glxinfo -B command I get an initial error at the start of the response as follows:
MESA: error: ZINK: failed to choose pdev
glx: failed to create drisw screen

Doing some digging on google I came across an issue with MESA where updating from 24.04 to 24.04.01 isn't updating the MESA driver to the latest versions which includes a fix for the issue I'm getting. Doing the following will update the MESA drivers and then everything worked fine:

sudo add-apt-repository ppa:kisak/kisak-mesa
sudo apt update
sudo apt upgrade

The link to the page where I found the info:

https://askubuntu.com/questions/1516040/mesa-and-glx-errors-when-running-glxinfo-ubuntu-24-04

Thanks you so much for this, it's a real life saver.

@tdcosta100
Copy link
Author

Very nice you were able to resolve your problem. Thanks for sharing the solution, I wasn't aware of this problem with MESA drivers.

@alecone
Copy link

alecone commented Dec 5, 2024

Hi, I am facing two issue in my case:

  1. The clipboard-sync is not working for me. Here are the logs i see:
    2024-12-05 09:36:28 - INFO - started clipboard sync manager 2024-12-05 09:36:28 - INFO - starting clipboard sync 2024-12-05 09:36:28 - WARN - Issue connecting to some x11 clipboards. This is expected when hooking up to gnome wayland, and not a problem in that context. Details: 'clipboard error: X11 clipboard error : XCB connection error: Connection' for x11 displays: [1..254] 2024-12-05 09:36:28 - INFO - Using clipboards: [X11Clipboard { display: ":0" }]
  2. When I have two displays attached, it does not recognize them and it always start on one monitor.

Can you help me fixing it?

@DanaGoyette
Copy link

Something to note about the wrapper: rather than just renaming the Xorg binary, it's better to dpkg-divert it:
sudo dpkg-divert --local --add --rename /usr/bin/Xorg
It will get renamed to /usr/bin/Xorg.distrib

Then make and mark executable the wrapper script, calling it /usr/bin/Xorg.

If you don't dpkg-divert it, the wrapper will get overwritten the next time the package is upgraded.

@Stixz
Copy link

Stixz commented Dec 7, 2024

I am completely new to linux and want to learn. I decided to try and start with WSL2/Ubuntu with a gui/desktop. I have managed to get the graphical.target to launch, but the problem, it doesn't quit launching. I am stuck in a endless cycle of the desktop loading and prompting me to login. Yes, I can login, but the desktops keep loading... lol Help?

@alecone
Copy link

alecone commented Dec 7, 2024

I am completely new to linux and want to learn. I decided to try and start with WSL2/Ubuntu with a gui/desktop. I have managed to get the graphical.target to launch, but the problem, it doesn't quit launching. I am stuck in a endless cycle of the desktop loading and prompting me to login. Yes, I can login, but the desktops keep loading... lol Help?

You just need to shut it down. It will close your wsl instance as well

@Stixz
Copy link

Stixz commented Dec 7, 2024

I am completely new to linux and want to learn. I decided to try and start with WSL2/Ubuntu with a gui/desktop. I have managed to get the graphical.target to launch, but the problem, it doesn't quit launching. I am stuck in a endless cycle of the desktop loading and prompting me to login. Yes, I can login, but the desktops keep loading... lol Help?

You just need to shut it down. It will close your wsl instance as well

Thanks for the reply. I have tried that, it still keeps loading multiple instances. I have even rebooted my PC and every time I launch it, it does it.

@tdcosta100
Copy link
Author

Hi, I am facing two issue in my case:

  1. The clipboard-sync is not working for me. Here are the logs i see:
    2024-12-05 09:36:28 - INFO - started clipboard sync manager 2024-12-05 09:36:28 - INFO - starting clipboard sync 2024-12-05 09:36:28 - WARN - Issue connecting to some x11 clipboards. This is expected when hooking up to gnome wayland, and not a problem in that context. Details: 'clipboard error: X11 clipboard error : XCB connection error: Connection' for x11 displays: [1..254] 2024-12-05 09:36:28 - INFO - Using clipboards: [X11Clipboard { display: ":0" }]
  2. When I have two displays attached, it does not recognize them and it always start on one monitor.

Can you help me fixing it?

For the problem with clipboard-sync I don't know how to help, maybe you should try to post a issue in their repository.

For the second problem, one solution (not an excellent one, though) is remove the -fullscreen switch of Xwayland and set the resolution to your combined monitors, for example, two 1920x1080 monitors would be a 3840x1080 resolution.

@tdcosta100
Copy link
Author

Something to note about the wrapper: rather than just renaming the Xorg binary, it's better to dpkg-divert it: sudo dpkg-divert --local --add --rename /usr/bin/Xorg It will get renamed to /usr/bin/Xorg.distrib

Then make and mark executable the wrapper script, calling it /usr/bin/Xorg.

If you don't dpkg-divert it, the wrapper will get overwritten the next time the package is upgraded.

Nice solution, I will put that in the tutorial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment