You are not logged in.

#1 2023-11-20 02:12:03

Cloudflash
Member
Registered: 2021-12-11
Posts: 14

Application did not properly obtain environment variables

hey guys!I am using a UHD screen. In order to make the application display as the right size, I set up QT_AUTO_SCREEN_SCALE_FACTOR = 2, but some applications do not work as expected, such as VMware-Workstation and VirtualBox.When I checked the environment variable of the process, I found that it was different from what I set.
Take VirtualBox as an example:

~ ❯ ps -ef | grep virtualbox                                                                                                                                                     at 09:42:40
myusername     10379    5696  9 10:02 ?        00:00:01 /usr/lib/virtualbox/VirtualBox
myusername     10398    1936  0 10:02 ?        00:00:00 /usr/lib/virtualbox/VBoxXPCOMIPCD
myusername     10404    1936  0 10:02 ?        00:00:00 /usr/lib/virtualbox/VBoxSVC --auto-shutdown
myusername     10526    7727  0 10:03 pts/1    00:00:00 grep --color=auto virtualbox
~ ❯ cat /proc/10379/environ | tr '\0' '\n'                                                                                                                                       at 10:03:07
SHELL=/bin/zsh
SESSION_MANAGER=local/laptop:@/tmp/.ICE-unix/2066,unix/laptop:/tmp/.ICE-unix/2066
XDG_CONFIG_DIRS=/home/myusername/.config/kdedefaults:/etc/xdg
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session1
GLFW_IM_MODULE=ibus
LANGUAGE=zh_CN
MEMORY_PRESSURE_WRITE=c29tZSAyMDAwMDAgMjAwMDAwMAA=
XMODIFIERS=@im=fcitx
DESKTOP_SESSION=plasmawayland
LC_MONETARY=en_US.UTF-8
GTK_RC_FILES=/etc/gtk/gtkrc:/home/myusername/.gtkrc:/home/myusername/.config/gtkrc
XCURSOR_SIZE=24
ANDROID_NDK=/opt/android-ndk
XDG_SEAT=seat0
PWD=/home/myusername
XDG_SESSION_DESKTOP=KDE
LOGNAME=myusername
XDG_SESSION_TYPE=wayland
SYSTEMD_EXEC_PID=5696
XAUTHORITY=/run/user/1000/xauth_ktQrZE
MOTD_SHOWN=pam
GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/myusername/.gtkrc-2.0:/home/myusername/.config/gtkrc-2.0
HOME=/home/myusername
LANG=en_US.UTF-8
LS_COLORS=
XDG_CURRENT_DESKTOP=KDE
MEMORY_PRESSURE_WATCH=/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/session.slice/plasma-plasmashell.service/memory.pressure
WAYLAND_DISPLAY=wayland-0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
INVOCATION_ID=1b0651e1411748379b262560821f2976
MANAGERPID=1936
ANDROID_NDK_HOME=/opt/android-ndk
KDE_SESSION_UID=1000
SDL_IM_MODULE=fcitx
XDG_ACTIVATION_TOKEN=kwin-16
XDG_SESSION_CLASS=user
ANDROID_HOME=/opt/android-sdk
USER=myusername
PLASMA_USE_QT_SCALING=1
KDE_SESSION_VERSION=5
QT_WAYLAND_FORCE_DPI=96
DISPLAY=:1
SHLVL=0
ANDROID_SDK_ROOT=/opt/android-sdk
LC_MEASUREMENT=en_US.UTF-8
XDG_VTNR=1
XDG_SESSION_ID=2
XDG_RUNTIME_DIR=/run/user/1000
VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/radeon_icd.x86_64.json
DEBUGINFOD_URLS=https://debuginfod.archlinux.org
LC_TIME=en_US.UTF-8
ANDROID_NDK_ROOT=/opt/android-ndk
QT_AUTO_SCREEN_SCALE_FACTOR=0
JOURNAL_STREAM=8:1213309
LC_COLLATE=en_US.UTF-8
XCURSOR_THEME=breeze_cursors
KDE_FULL_SESSION=true
QSG_RENDER_LOOP=threaded
PATH=/usr/bin:/bin:/usr/sbin:/sbin
SAL_USE_VCLPLUGIN=gtk3_kde5
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
KDE_APPLICATIONS_AS_SCOPE=1
MAIL=/var/spool/mail/myusername
LC_NUMERIC=en_US.UTF-8
OLDPWD=/home/myusername
~ ❯ echo $QT_AUTO_SCREEN_SCALE_FACTOR                                                                                                                                            at 10:03:21
2

Does anyone encounter the same problem?
my envirmonent
init:systemd
Display Manager:SDDM
Display Server:wayland
Window Manager:kwin
Desktop Environment:KDE

Offline

#2 2023-11-20 03:35:32

mpan
Member
Registered: 2012-08-01
Posts: 1,133
Website

Re: Application did not properly obtain environment variables

Hello. I can’t help VirtualBox or QT_AUTO_SCREEN_SCALE_FACTOR specifically, as I use neither. But, from a more general perspective, check the process tree.

Environment variables are inherited from parent process. If QT_AUTO_SCREEN_SCALE_FACTOR is set in a different branch of the process tree than the one in which VirtualBox runs, VirtualBox will never see it.

You may inspect process tree using htop: F5 to switch to tree view. Also ‘e’ to see environment of the given process.

Last edited by mpan (2023-11-20 03:35:58)


Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#3 2023-11-20 08:14:17

Cloudflash
Member
Registered: 2021-12-11
Posts: 14

Re: Application did not properly obtain environment variables

mpan wrote:

Hello. I can’t help VirtualBox or QT_AUTO_SCREEN_SCALE_FACTOR specifically, as I use neither. But, from a more general perspective, check the process tree.

Environment variables are inherited from parent process. If QT_AUTO_SCREEN_SCALE_FACTOR is set in a different branch of the process tree than the one in which VirtualBox runs, VirtualBox will never see it.

You may inspect process tree using htop: F5 to switch to tree view. Also ‘e’ to see environment of the given process.

Thanks for your reply! I followed your instructions and performed troubleshooting. The process gradation I found is [systemd] --> [systemd --user] --> [plasmashell] --> [virtualbox]. So, in the [systemd --user] environment, I can find QT_AUTO_SCREEN_SCALE_FACTOR=2, but I couldn't find it in the plasmashell environment. This is quite strange!

~ ❯ ps -ef | grep systemd                                                           at 16:07:48
root           1       0  0 14:19 ?        00:00:01 /usr/lib/systemd/systemd --switched-root --system --deserialize=40 splash
root         407       1  0 14:19 ?        00:00:03 /usr/lib/systemd/systemd-journald
root         467       1  0 14:19 ?        00:00:00 /usr/lib/systemd/systemd-udevd
dbus         905       1  0 14:19 ?        00:00:01 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
root         908       1  0 14:19 ?        00:00:00 /usr/lib/systemd/systemd-logind
root         909       1  0 14:19 ?        00:00:00 /usr/lib/systemd/systemd-machined
myusername      1934       1  0 14:19 ?        00:00:00 /usr/lib/systemd/systemd --user
myusername      1961    1934  0 14:19 ?        00:00:01 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
myusername     16587   16186  0 16:07 pts/4    00:00:00 grep --color=auto systemd

~ ❯ sudo cat /proc/1934/environ | tr '\0' '\n'                                                                                                                          
LANG=en_US.UTF8
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin
NOTIFY_SOCKET=/run/systemd/notify
HOME=/home/myusername
LOGNAME=myusername
USER=myusername
SHELL=/bin/zsh
INVOCATION_ID=ea3856f2fff14a1fb9208169abebc85f
JOURNAL_STREAM=8:17327
SYSTEMD_EXEC_PID=1934
MAIL=/var/spool/mail/myusername
XDG_RUNTIME_DIR=/run/user/1000
XMODIFIERS=@im=fcitx
SDL_IM_MODULE=fcitx
GLFW_IM_MODULE=ibus
QT_AUTO_SCREEN_SCALE_FACTOR=2
~ ❯ ps -ef | grep plasmashell                                                                                                                                                  
myusername      2083    1934  2 14:19 ?        00:02:44 /usr/bin/plasmashell --no-respawn
myusername     16636   16186  0 16:08 pts/4    00:00:00 grep --color=auto plasmashell

~ ❯ cat /proc/2083/environ | tr '\0' '\n'                                                                                                                                      
GLFW_IM_MODULE=ibus
HOME=/home/myusername
LANG=en_US.UTF-8
LOGNAME=myusername
MAIL=/var/spool/mail/myusername
PATH=/usr/lib/safe-rm:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/local/go/bin:/opt/android-ndk:/opt/android-sdk/platform-tools:/opt/android-sdk/tools:/opt/android-sdk/tools/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/rustup/bin
QT_AUTO_SCREEN_SCALE_FACTOR=0
....

Offline

#4 2023-11-20 09:17:28

mpan
Member
Registered: 2012-08-01
Posts: 1,133
Website

Re: Application did not properly obtain environment variables

Not using Plasma either. Given plasmashell is a part of desktop environment, perhaps some configuration option in DE affects it and makes plasmashell override the value? For example I found a mention of scaling settings for Plasma.


Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#5 2023-11-20 20:54:54

espritlibre
Member
Registered: 2022-12-15
Posts: 112

Re: Application did not properly obtain environment variables

i tried your commands and my set qt variables do show up for virtualbox, but i'm on gnome/wayland and scale through gnome-settings-daemon.
my qt related variables set in /etc/environment are:

...
QT_QPA_PLATFORM=wayland
QT_AUTO_SCREEN_SCALE_FACTOR=1
QT_ENABLE_HIGHDPI_SCALING=1
...

the latter 2 should be set for compatibility between different version of qt

EDIT:
ArchWiki HiDPI

Last edited by espritlibre (2023-11-20 20:58:48)

Offline

#6 2023-11-21 02:31:51

Cloudflash
Member
Registered: 2021-12-11
Posts: 14

Re: Application did not properly obtain environment variables

mpan wrote:

Not using Plasma either. Given plasmashell is a part of desktop environment, perhaps some configuration option in DE affects it and makes plasmashell override the value? For example I found a mention of scaling settings for Plasma.

I've checked, and unfortunately, that doesn't work. It seems that Plasma has settings with a higher priority than environment variables. : (

Offline

#7 2023-11-21 02:34:17

Cloudflash
Member
Registered: 2021-12-11
Posts: 14

Re: Application did not properly obtain environment variables

espritlibre wrote:

i tried your commands and my set qt variables do show up for virtualbox, but i'm on gnome/wayland and scale through gnome-settings-daemon.
my qt related variables set in /etc/environment are:

...
QT_QPA_PLATFORM=wayland
QT_AUTO_SCREEN_SCALE_FACTOR=1
QT_ENABLE_HIGHDPI_SCALING=1
...

the latter 2 should be set for compatibility between different version of qt

EDIT:
ArchWiki HiDPI



I also tried adding these variables to the /etc/environment file and restarted my laptop. Unfortunately, they still don't take effect. It seems that Plasma is preventing them from working.

Offline

Board footer

Powered by FluxBB