Skip to content

Instantly share code, notes, and snippets.

@tdcosta100
Last active March 29, 2025 13:32
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 [email protected] service:

    sudo systemctl edit [email protected]
    
  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).

@tdcosta100
Copy link
Author

I'm sorry I didn't update the tutorial yet, I've been very busy these last weeks. But this is still on my to-do things to update, don't worry, I didn't forget.

@InfiniteBSOD
Copy link

A stupid question but I’m stuck here:
https://gist.github.com/tdcosta100/e28636c216515ca88d1f2e7a2e188912#replacing-default-xorg-by-xwayland

The system can’t find a file called /usr/bin/Xorg.

I’m running Ubuntu 24.04 on WSL2 and followed the previous steps in the guide. Is there something I’ve missed or which is implied?

Thanks!

@kfoxirl
Copy link

kfoxirl commented Jan 22, 2025 via email

@InfiniteBSOD
Copy link

InfiniteBSOD commented Jan 23, 2025

Did you check if it got installed elsewhere? sudo find / -iname xorg 2>/dev/null

Thanks, tried the command but it doesn't find anything.
I am running an offline installation of "Ubuntu 2404.1.24.0" with a kernel of 5.15.167-4 on Windows 10 22H2 (OS Build: 19045.4894).
With "offline" I mean that I downloaded the ".appxbundle" and extracted the ".appx"-file within it, extracted the .appx in turn and put the content of those files on my harddrive.

I am on an airgapped network so that is why.

However when I tried the same command on my machine at home running Windows 11 and Ubuntu 24.04 then the command returned that it found "Xorg".

Hmm.......

Update:

Checked my computer at home:
Ubuntu 24.04.1 running kernel 5.16.167-4
My OS is Windows 11 24H2 (OS Build: 26100.2894)

apt list --installed | grep xorg returns the following:

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

xorg-docs-core/noble,now 1:1.7.1-1.2 all [installed,automatic]
xorg-sgml-doctools/noble,now 1:1.11-1.1 all [installed,automatic]
xorg/noble,now 1:7.7+23ubuntu3 amd64 [installed,automatic]
xserver-xorg-core/noble-updates,noble-security,now 2:21.1.12-1ubuntu1.1 amd64 [installed,automatic]
xserver-xorg-input-all/noble,now 1:7.7+23ubuntu3 amd64 [installed,automatic]
xserver-xorg-input-libinput/noble,now 1.4.0-1build1 amd64 [installed,automatic]
xserver-xorg-input-wacom/noble,now 1:1.2.0-1ubuntu2 amd64 [installed,automatic]
xserver-xorg-legacy/noble-updates,noble-security,now 2:21.1.12-1ubuntu1.1 amd64 [installed,automatic]
xserver-xorg-video-all/noble,now 1:7.7+23ubuntu3 amd64 [installed,automatic]
xserver-xorg-video-amdgpu/noble,now 23.0.0-1build1 amd64 [installed,automatic]
xserver-xorg-video-ati/noble,now 1:22.0.0-1build1 amd64 [installed,automatic]
xserver-xorg-video-fbdev/noble,now 1:0.5.0-2build2 amd64 [installed,automatic]
xserver-xorg-video-intel/noble,now 2:2.99.917+git20210115-1build1 amd64 [installed,automatic]
xserver-xorg-video-nouveau/noble,now 1:1.0.17-2build1 amd64 [installed,automatic]
xserver-xorg-video-qxl/noble,now 0.1.6-1build1 amd64 [installed,automatic]
xserver-xorg-video-radeon/noble,now 1:22.0.0-1build1 amd64 [installed,automatic]
xserver-xorg-video-vesa/noble,now 1:2.6.0-1 amd64 [installed,automatic]
xserver-xorg-video-vmware/noble,now 1:13.4.0-1build1 amd64 [installed,automatic]
xserver-xorg/noble,now 1:7.7+23ubuntu3 amd64 [installed,automatic]

sudo find / -iname xorg 2>/dev/null returns the following:

/usr/include/xorg
/usr/bin/Xorg
/usr/share/bug/xorg
/usr/share/lintian/overrides/xorg
/usr/share/doc/xorg
/usr/share/X11/xkb/rules/xorg
/usr/lib/xorg
/usr/lib/xorg/Xorg

Will check the same commands at my computer at work and update.

Update (again):

On my work computer running apt list --installed | grep xorg returns the following:

xorg-docs-core/noble,now 1:1.7.1-1.2 all [installed,automatic]
xorg-sgml-doctools/noble,now 1:1.11-1.1 all [installed,automatic]

I installed "xorg" by apt install xorg and then re-ran apt list --installed | grep xorg which returned:

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

xorg-docs-core/noble,now 1:1.7.1-1.2 all [installed,automatic]
xorg-sgml-doctools/noble,now 1:1.11-1.1 all [installed,automatic]
xorg/noble,now 1:7.7+23ubuntu3 amd64 [installed,automatic]
xserver-xorg-core/noble-updates,noble-security,now 2:21.1.12-1ubuntu1.1 amd64 [installed,automatic]
xserver-xorg-input-all/noble,now 1:7.7+23ubuntu3 amd64 [installed,automatic]
xserver-xorg-input-libinput/noble,now 1.4.0-1build1 amd64 [installed,automatic]
xserver-xorg-input-wacom/noble,now 1:1.2.0-1ubuntu2 amd64 [installed,automatic]
xserver-xorg-legacy/noble-updates,noble-security,now 2:21.1.12-1ubuntu1.1 amd64 [installed,automatic]
xserver-xorg-video-all/noble,now 1:7.7+23ubuntu3 amd64 [installed,automatic]
xserver-xorg-video-amdgpu/noble,now 23.0.0-1build1 amd64 [installed,automatic]
xserver-xorg-video-ati/noble,now 1:22.0.0-1build1 amd64 [installed,automatic]
xserver-xorg-video-fbdev/noble,now 1:0.5.0-2build2 amd64 [installed,automatic]
xserver-xorg-video-intel/noble,now 2:2.99.917+git20210115-1build1 amd64 [installed,automatic]
xserver-xorg-video-nouveau/noble,now 1:1.0.17-2build1 amd64 [installed,automatic]
xserver-xorg-video-qxl/noble,now 0.1.6-1build1 amd64 [installed,automatic]
xserver-xorg-video-radeon/noble,now 1:22.0.0-1build1 amd64 [installed,automatic]
xserver-xorg-video-vesa/noble,now 1:2.6.0-1 amd64 [installed,automatic]
xserver-xorg-video-vmware/noble,now 1:13.4.0-1build1 amd64 [installed,automatic]
xserver-xorg/noble,now 1:7.7+23ubuntu3 amd64 [installed,automatic]

so "xorg" wasn't installed, I guess I pulled it as a dependency on my computer at home without reflecting over it.

@Adhjie
Copy link

Adhjie commented Jan 25, 2025

@ tdcosta100
Okay, also sorry for me pinging you. I just need this to be seen by all users, since it's very important. without that everytime anything update Xorg, it'll get overwritten by the original one if not for dpkg-divert.

@veselinoWiktor
Copy link

Hello,

I followed all the steps with brand new installation of the ubuntu distro in wsl, but I when I run sudo systemctl start graphical.target I get black window, when I waited some time the Home folder poped but still black window, and then this lagged window
Screenshot 2025-02-05 122214

@stefanlack
Copy link

stefanlack commented Feb 17, 2025

Very nice! Thank you.

May it be possible to share clipboard (for copy und paste of text) between windows host and ubuntu-vm? I have installed xubuntu / xfce desktop in my wsl and copy-paste is not working.

Second: I just uses only my primary monitor. I have not investigated yet, but it is possible to use a dual monitor setup? This would be wonderfull.

@mwoodpatrick
Copy link

mwoodpatrick commented Feb 17, 2025

Many thanks for creating this, this worked pretty well for me.

I would like to be able to switch between the Ubuntu Wayland desktop and the windows desktop and these commands worked for me:

sudo systemctl isolate graphical.target

sudo systemctl isolate multi-user.target

is there a better way?

I created a couple of aliases:

alias udesk="sudo systemctl isolate graphical.target"

alias wdesk="sudo systemctl isolate multi-user.target"

@jfmherokiller
Copy link

jfmherokiller commented Feb 17, 2025

@jfmherokiller since this is for gnome, what steps do you change to get plasma KDE? running? isnt it SDDM instead of Mutter?

edit: sorry mixed it up, thats LXQt, Kwin for KDe rite?

I believe I used startplasma-x11 or /usr/lib/plasma-dbus-run-session-if-needed /usr/bin/startplasma-wayland

i cant remember which one

@mwoodpatrick
Copy link

On my other laptop I'm getting the error message:

Feb 17 15:44:51 mlwphpenvy360 /usr/libexec/gdm-wayland-session[1515]: dbus-daemon[1515]: [session uid=123 pid=1515] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1

Does anyone have any suggestions on how to debug?

@Adhjie
Copy link

Adhjie commented Feb 18, 2025

@stefanlack
Not really cross copy paste between windows and wsl but I use pano clipboard for gnome desktop ubuntu. I copy paste it to a note, and then copy paste the note to a windows folder in /mnt/c/ sampleFolder and vice versa.
I use vscodium in windows and gnome-text-editor in the wsl DE.

I technically could use syncthing for it but i haven't got the time to set it up on Linux. So IDK, if the GUI also maintained or linux only got CLI one.

@mwoodpatrick
Copy link

mwoodpatrick commented Feb 23, 2025

I added this code snippet to my .bashrc to help with copy and paste

if grep -qEi "(Microsoft|WSL)" /proc/version; then
    echo "Running on WSL"
    alias wcopy='/mnt/c/windows/system32/clip.exe'
    alias wpaste='/mnt/c/windows/system32/paste.exe'
else
    echo "Not running on WSL"
fi

clip.exe is installed on windows by default but you need to manually add paste.exe

  1. clip | Microsoft Learn
  2. MS-DOS Commands :: clip (Copy command output to Windows Clipboard)
  3. MS-DOS Commands :: paste (Paste Windows Clipboard to command input)
  4. paste.exe
  5. paste.exe

paste.exe depends on .NET Framework 3.5 (includes .NET 2.0 and 3.0) which windows will install if you don't already have it

@Adhjie
Copy link

Adhjie commented Feb 24, 2025

Does that copy-paste works even with DE that use Wayland?

@mwoodpatrick
Copy link

yes

@Timbo303
Copy link

Im having trouble getting audio to work on apps like waydroid and firefox inside the desktop. Is there is a fix?

@mwoodpatrick
Copy link

Has anyone gotten this to work with NixOS I would love to have this working

@manusevo
Copy link

manusevo commented Mar 7, 2025

Thanks for the guide everything works fine. 👍 I use multiple screens. Is there a setting to choose which screen to show the wsl on?

@shlomoa
Copy link

shlomoa commented Mar 7, 2025

This solution worked great
Until it broke, Finding strange errors in the journal
Files being deleted, restored . . .
I wish someone (Microsoft?) would automate publish and support it

@praveenkjvs
Copy link

Thanks. Can you suggest how to RDP into Ubuntu 24.04 without xrdp and just using Gnome's native remote desktop control?

@mrhash782
Copy link

Is it possible to get the audio working for Ubuntu with this?

@kfoxirl
Copy link

kfoxirl commented Mar 18, 2025 via email

@nixpare
Copy link

nixpare commented Mar 19, 2025

@tdcosta100 incredible work! Everything works perfectly.
I saw that in the script you move the XDG_RUNTIME_DIR to a folder in the user home, with only the two symlinks for the wayland socket, but do you know why it does not work under the original /run/user/1000 directory? I tried and it complained that it couldn't find the X1 display ... I can't see the reason and the connection between runtime dir, wayland socket and it not finding the X display.
Btw this is just curiosity

@nixpare
Copy link

nixpare commented Mar 19, 2025

@stefanlack @Adhjie @mwoodpatrick I already had around a script which pipes the clipboard between the X0 and X1, and considering that wslg automatically handles the X0 clipboard, it syncs with everything automatically. The only dipendency is xclip to be installed on wsl.

#!/bin/sh

sleep 5

get_xclip() {
        local content=`xclip -display $1 -selection clipboard -o 2>/dev/null`

        if [ $? -eq 0 ]; then
                printf "$content"
                return 0
        fi

        if [ "$1" == ":0" ]; then
                printf "Fatal"
                return 0
        fi

        xclip -display :0 -selection clipboard -o 2>/dev/null
        return 0
}

curr0=""
prev0=""
curr1=""
prev1=""

while true; do
        [ ! -e /tmp/.X11-unix/X$1 ] && break

        curr0=`get_xclip :0 2>/dev/null`
        if [ "$curr0" != "$prev0" ]; then
                printf "$curr0" | xclip -selection clipboard -d :$1
                prev0="$curr0"
                prev1="$curr0"
                curr1="$curr0"
        fi

        sleep 0.5

        [ ! -e /tmp/.X11-unix/X$1 ] && break

        curr1=`get_xclip :$1 2>/dev/null`
        if [ "$curr1" != "$prev1" ]; then
                printf "$curr1" | xclip -selection clipboard -d :0
                prev1="$curr1"
                prev0="$curr1"
                curr0="$curr1"
        fi

        sleep 0.5
done

If you save the file as pipe-xclip under $HOME/bin/ and make it executable, you just need to add to the /usr/bin/Xorg.Xwayland file, before the exec command, this line:

$HOME/bin/pipe-xclip ${displayNumber} >/dev/null 2>&1 &

exec "${command[@]}"

EDIT: I updated the script and the script call above because before it was hardcoded to sync the clipboard between :0 and :1

@Adhjie
Copy link

Adhjie commented Mar 20, 2025

@Timbo303
I think audio needs a hack to work in wsl. Iirc something like pulse audio.
I kinda give up on this since I'm busy.
I was going to set up waydroid to avoid windows proprietary emulator. But it's not a program that work out-of-the-box.

GUI setup in WSL is really experimental since it's primarily pushed for CLI that devs use.

@Adhjie
Copy link

Adhjie commented Mar 20, 2025

@nixpare
Thanks for the workaround. I hope that's stable, is it a built-in feature under WSL?

Pano currently supports the latest gnome-shell only in the beta build, so applying it each time beta build is released is a pain for me.

Edit:
Wordings

About Syncthing, the official package is also launched just like in windows. Minus terminal that pops up on desktop.
I think I'll debug later, I need to find the config file to reset my GUI password.

Syncthing technically could synced notes, between OSes, after copy pasting the text from pano to a note inside Syncthing folder.

@nixpare
Copy link

nixpare commented Mar 20, 2025

@Adhjie WSLg already syncs the clipboard between the windows host and every gui app running under the wayland-0 and :0 displays.
My script basically is just a loop that every half a second checks if there is a new clipboard content in both :0 and :1 displays.
The script instantly dies as soon as the :1 display server stops or resets.
This should not interfere in any way with other programs used to manage the clipboard, so Pano and others should work as expected.

If you want to try it out without putting it in the Xorg launch file, you can run it in any console after you started GNOME, just pipe-xclip and CTRL-C to exit.

Btw: I only tried text-like content, like words and links, not tried other things like files.

@nixpare
Copy link

nixpare commented Mar 20, 2025

@tdcosta100 @mrhash782 I found out that if you also link the pipewire files from the original XDG_RUNTIME_DIR the audio works using WSLg. You can do this by deleting the $HOME/runtime-dir created by the Xorg.Xwayland script, adding this line to the script and relaunching the grafical target.

...

  # 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/
+  ln -s $XDG_RUNTIME_DIR/pipewire-0 $XDG_RUNTIME_DIR/pipewire-0.lock $HOME/runtime-dir/
  fi

...

@plantroon
Copy link

Please, anyone who has nVidia GPU and could confirm if they can play let's say a 4k60 video with this setup smoothly? I managed to get it running but I am on a VFIO setup so this is a nested VM and it's not exactly .. fast .. :D Mine's dropping half the frames basically. So I wonder if it's the viewing mechanism or the nested virt.

@Adhjie
Copy link

Adhjie commented Mar 25, 2025

@plantroon
I think there are a lot of factors there, WSL itself is a VM. What is the host machine, what method do you use to nested it?

I think the framerate is dependent on this value inside the monitors.xml config file:

<rate>59.963</rate>

IDK if framerate is also dependent on the GPU acceleration feature. If it is then NVIDIA only has that feature for CUDA inside WSL.

I think others could chime in more on this. You could also ask in other forums like r/linux_gaming where there are a lot of NVIDIA on linux discussions there.

Edit:
Add tag.

@kfoxirl
Copy link

kfoxirl commented Mar 25, 2025 via email

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