从批处理脚本启动 WSL 的 GUI

从批处理脚本启动 WSL 的 GUI
edit 

- my specs:
win 10  (10.0.18362 Build 18362)
Ubuntu LTS (18.04)


- Topic Enivornment Variable:
Maybe i have named this sub topic wrong...
necessarry settings:
in ~/.bashrc add: 
export DISPLAY=:0.0

当您使用 Windows Subsystem for Linux (WSL) 时,您可以通过以下方式从 Windows 主机系统运行批处理文件中的命令:

wsl 'example command'

如果你现在想要启动任何类型的图形界面(例如 xfce),可以使用以下命令(在 wsl-shell 中执行):

startxfce4

或者

xfce4-session

但是如果您知道想要创建一个启动批处理文件(x11-server 正在运行!):

wsl startxfce4

存在以下问题:

X.Org X Server 1.19.6
Release Date: 2017-12-20
X Protocol Version 11, Revision 0
Build Operating System: Linux 4.4.0-148-generic x86_64 Ubuntu
Current Operating System: Linux DESKTOP-6FQD834 4.4.0-18362-Microsoft #1-Microsoft Mon Mar 18 12:02:00 PST 2019 x86_64
Kernel command line: BOOT_IMAGE=/kernel init=/init
Build Date: 03 June 2019  08:10:35AM
xorg-server 2:1.19.6-1ubuntu4.3 (For technical support please see http://www.ubuntu.com/support)
Current version of pixman: 0.34.0
        Before reporting problems, check http://wiki.x.org
        to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
        (++) from command line, (!!) notice, (II) informational,
        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Mon Oct 14 06:47:57 2019
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
(EE)
Fatal server error:
(EE) parse_vt_settings: Cannot open /dev/tty0 (Input/output error)
(EE)
(EE)
Please consult the The X.Org Foundation support
         at http://wiki.x.org
 for help.
(EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
(EE)
(EE) Server terminated with error (1). Closing log file.

我猜错误源于你必须在 wsl 中设置一个环境变量:图形输出应该指向哪个监视器(x11-server)...我的猜测是:wsl 尝试在子系统完全初始化之前启动 xfce4(=所有环境变量都已加载,等等)

所以我尝试了一些类似的事情:

wsl
sleep 10
wsl startxfce4

但这就像只有第一行代码......

如果我单独执行所有步骤,一切都会正常......

相关内容