-1

So I have just started using Auto Hotkeys to shortcut some things I have to do. One of these is to make Windows+Shift+L a shortcut to launch my virtual desktop.

Some notes:

  • I am on Windows 10 Home (Version 2004)
  • I am using WSL2
  • I am using Ubuntu 20.04
  • I am using XLaunch for XServer

The AHK file looks like:

; Global hotkeys
#+l::Run, C:\Users\conne\WSL\linuxmachine.bat

This file runs my batch file which is where the issues are coming from.

To get my virtual desktop to run, I have to run my XLaunch file to run XServer, then (in Ubuntu 20.04) run

startxfce4

I have tried doing this through a batch file as shown below.

START C:\Users\conne\WSL\XLaunch.xlaunch

wsl.exe startxfce4

This will start the XServer fine, but when it has to run the xfce4 startup, I get an error message:

/usr/bin/startxfce4: Starting X server

/usr/lib/xorg/Xorg.wrap: Only console users are allowed to run the X server

My guess is the machine is denying me access to run the command unless I am actually using Ubuntu, instead of this method.

Any suggestions would be greatly appreciated!

1 Answers1

2

You are not authorized to run X server. To change this, edit /etc/X11/Xwrapper.config so that it says:

allowed_users=anybody
needs_root_rights=yes

After this is done, you will quite possibly encounter another problem which will say that no screens are found. I don't know if you noticed this but if you create an alias in ~/.bashrc and try to run it with "wsl command" it will not accept it saying command not found. This means that you need to make it so that wsl.exe also looks at ~/.bashrc file before executing anything, because DISPLAY configurations are located in that file.

I will paste the solution I found from here https://superuser.com/questions/1444767/how-to-use-alias-created-commands-with-wsl-command-wsl-ubuntu

wsl bash -ic command

So in this case it would be

wsl bash -ic startxfce4

After executing this, if display is configured properly in the .bashrc file, it should work. It worked for me anyway.

Yuri
  • 4,254
  • 1
  • 29
  • 46
Naeloath
  • 21
  • 2