![如何摆脱:警告:忽略 Gnome 上的 XDG_SESSION_TYPE=wayland。无论如何,使用 QT_QPA_PLATFORM=wayland 在 Wayland 上运行。(Ubuntu 22.04)](https://linux22.com/image/951744/%E5%A6%82%E4%BD%95%E6%91%86%E8%84%B1%EF%BC%9A%E8%AD%A6%E5%91%8A%EF%BC%9A%E5%BF%BD%E7%95%A5%20Gnome%20%E4%B8%8A%E7%9A%84%20XDG_SESSION_TYPE%3Dway%E2%80%8B%E2%80%8Bland%E3%80%82%E6%97%A0%E8%AE%BA%E5%A6%82%E4%BD%95%EF%BC%8C%E4%BD%BF%E7%94%A8%20QT_QPA_PLATFORM%3Dwayland%20%E5%9C%A8%20Wayland%20%E4%B8%8A%E8%BF%90%E8%A1%8C%E3%80%82%EF%BC%88Ubuntu%2022.04%EF%BC%89.png)
我在 Ubuntu 22.04.2 LTS 上,收到很多有关 syslog 的日志消息
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
提供此功能的程序包括notepadqq.desktop
、gsd-media-keys
和org.flameshot.Flameshot
。下面是示例。我从 Dock 上的快捷方式启动 notepadqq,然后会得到以下结果var/log/syslog
:
Apr 14 13:16:34 niko-ubuntu systemd[1853]: Started Application launched by gnome-shell.
Apr 14 13:16:34 niko-ubuntu notepadqq.desktop[12430]: Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
Apr 14 13:16:34 niko-ubuntu notepadqq.desktop[12430]: QSocketNotifier: Can only be used with threads started with QThread
查看 notepadqq 进程 (12430) 的环境变量时,我发现它具有QT_QPA_PLATFORM=wayland
:
niko@niko-ubuntu:/var/log$ cat /proc/12430/environ | tr '\0' '\n'
GJS_DEBUG_TOPICS=JS ERROR;JS LOG
LC_TIME=fi_FI.UTF-8
USER=niko
XDG_SESSION_TYPE=wayland
SHLVL=0
HOME=/home/niko
DESKTOP_SESSION=ubuntu
GIO_LAUNCHED_DESKTOP_FILE=/usr/share/applications/notepadqq.desktop
GTK_MODULES=gail:atk-bridge
GNOME_SHELL_SESSION_MODE=ubuntu
LC_MONETARY=fi_FI.UTF-8
MANAGERPID=1853
SYSTEMD_EXEC_PID=2068
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
GIO_LAUNCHED_DESKTOP_FILE_PID=12430
IM_CONFIG_PHASE=1
WAYLAND_DISPLAY=wayland-0
LOGNAME=niko
_=/usr/bin/gnome-session
JOURNAL_STREAM=8:31438
PYTHONBREAKPOINT=IPython.embed
XDG_SESSION_CLASS=user
USERNAME=niko
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
PATH=/home/niko/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
SESSION_MANAGER=local/niko-ubuntu:@/tmp/.ICE-unix/2047,unix/niko-ubuntu:/tmp/.ICE-unix/2047
INVOCATION_ID=335082c2c31843c5974cbbe32e6a44ea
LC_ADDRESS=fi_FI.UTF-8
XDG_RUNTIME_DIR=/run/user/1000
XDG_MENU_PREFIX=gnome-
GNOME_SETUP_DISPLAY=:1
DISPLAY=:0
LANG=en_US.UTF-8
LC_TELEPHONE=fi_FI.UTF-8
XDG_CURRENT_DESKTOP=ubuntu:GNOME
XDG_SESSION_DESKTOP=ubuntu
XMODIFIERS=@im=ibus
XAUTHORITY=/run/user/1000/.mutter-Xwaylandauth.G2DN31
SSH_AGENT_LAUNCHER=gnome-keyring
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
LC_NAME=fi_FI.UTF-8
SHELL=/bin/bash
QT_ACCESSIBILITY=1
GDMSESSION=ubuntu
LC_MEASUREMENT=fi_FI.UTF-8
LC_IDENTIFICATION=fi_FI.UTF-8
GJS_DEBUG_OUTPUT=stderr
QT_IM_MODULE=ibus
PWD=/home/niko
QT_QPA_PLATFORM=wayland
XDG_DATA_DIRS=/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
LC_NUMERIC=fi_FI.UTF-8
LC_PAPER=fi_FI.UTF-8
我在我的 中有这个设置~/.profile
:
export QT_QPA_PLATFORM=wayland
从终端启动程序时我也会看到同样的警告:
niko@niko-ubuntu:/var/log$ echo $QT_QPA_PLATFORM
wayland
niko@niko-ubuntu:/var/log$ notepadqq
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
QSocketNotifier: Can only be used with threads started with QThread
为什么我会收到此警告?我该如何消除它?