Skip to content

utils: preserve more KDE-related environment variables #1696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bkoropoff
Copy link
Contributor

I noticed that Qt applications run in my toolbox container on Fedora Kinoite 42 did not respect KDE's theme or display scaling settings. It turns out this was due to the KDE_SESSION_VERSION environment variable missing. I went through all environment variables which KDE and konsole set in my session which weren't preserved and added them to the list for completeness. Let me know if you want some removed or split into separate commits.

@bkoropoff bkoropoff requested a review from debarshiray as a code owner August 6, 2025 02:40
debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Aug 6, 2025
A KDE session sets some environment variables to influence the behaviour
of various programs and to access various settings [1].  eg., if the
KDE_SESSION_VERSION environment variable is absent then applications
won't respect KDE's theme or display scaling settings.

These environment variables are not meant to be set by the shell's
start-up scripts, but directly by KDE, and hence needs to be preserved
across the host operating system and Toolbx container.

[1] https://userbase.kde.org/KDE_System_Administration/Environment_Variables

containers#1696
debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Aug 6, 2025
A KDE session sets some environment variables to influence the behaviour
of various programs and to access various settings [1].  eg., if the
KDE_SESSION_VERSION environment variable is absent then applications
won't respect KDE's theme or display scaling settings.

These environment variables are not meant to be set by the shell's
start-up scripts, but directly by KDE, and hence needs to be preserved
across the host operating system and Toolbx container.

[1] https://userbase.kde.org/KDE_System_Administration/Environment_Variables

containers#1696
containers#1698
debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Aug 7, 2025
A KDE session sets some environment variables to influence the behaviour
of various programs and to access various settings [1].  eg., if the
KDE_SESSION_VERSION environment variable is absent then applications
won't respect KDE's theme or display scaling settings.

These environment variables are not meant to be set by the shell's
start-up scripts, but directly by KDE, and hence needs to be preserved
across the host operating system and Toolbx container.

[1] https://userbase.kde.org/KDE_System_Administration/Environment_Variables

containers#1696
containers#1698
Copy link
Member

@debarshiray debarshiray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch, @bkoropoff !

I didn't have time to go through all the environment variables. However, KDE_FULL_SESSION and KDE_SESSION_VERSION look obviously correct, based on your report and the KDE documentation. Therefore, I split them into #1698 to be able to include them in the new Toolbx release that I am preparing, so that at least some of your problems are addressed soon.

Hey @grulja ! Do you have any comments on preserving the values of these environment variables inside Toolbx containers?

Sometimes I think that we should change Toolbx's current approach of preserving only some environment variables, particularly those that are not set by the user in their shell start-up files, to one where it preserves all variables.

Copy link
Member

@debarshiray debarshiray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to add tests for any of these environment variables that you think can be useful.

@grulja
Copy link

grulja commented Aug 7, 2025

For the record, I have the same setup (Kinoite 42) and I don't have any issue with Qt applications not being properly scaled or themed when running inside Toolbox. I really wonder whether KDE_SESSION_VERSION has any impact on this, I would rather say it's used so others can find out whether you run KDE Plasma 5 or KDE Plasma 6. Still, it won't definitely hurt preserving this env variable, same for KDE_FULL_SESSION.

@bkoropoff
Copy link
Contributor Author

I definitely see different behavior, e.g.:

toolbox run qdbusviewer-qt6:
image

toolbox run env KDE_SESSION_VERSION=6 qdbusviewer-qt6:
image

qdbusviewer seems to pick up scaling regardless, but audacious doesn't without the environment variable set. This might have something to do with audacious running through XWayland.

@bkoropoff
Copy link
Contributor Author

If toolbox continues to preserve only some environment variables, it might be good to make the list configurable through files in XDG_CONFIG_HOME and XDG_CONFIG_DIRS (thus picking up system defaults in /etx/xdg). This would allow both users and distributions/packages to add variables to the list.

debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Aug 7, 2025
Konsole injects the name of the current profile, and the identifiers
of the current tab and window into the process running inside it
through the KONSOLE_PROFILE_NAME, KONSOLE_DBUS_SESSION and
KONSOLE_DBUS_WINDOW environment variables respectively [1,2,3].  These
are used by programs like Neovim to detect the terminal features
supported by Konsole [4,5], or by users to save the shell's history
separately for each profile, tab or window [6].

These environment variables are not meant to be set by the shell's
start-up scripts, but directly by Konsole, and hence needs to be
preserved across the host operating system and Toolbx container.

Note that KONSOLE_PROFILE_NAME was later removed from Konsole [7].
However, Neovim still uses it, so it's better to preserve it.

[1] Konsole commit debfec2eb3c8ede8
    https://invent.kde.org/utilities/konsole/-/commit/debfec2eb3c8ede8
    https://bugs.kde.org/show_bug.cgi?id=227296

[2] Konsole commit fcd815256c3729f2
    https://invent.kde.org/utilities/konsole/-/commit/fcd815256c3729f2

[3] Konsole commit 07cddfe302233c35
    https://invent.kde.org/utilities/konsole/-/commit/07cddfe302233c35
    https://bugs.kde.org/show_bug.cgi?id=276912
    https://bugs.kde.org/show_bug.cgi?id=281513
    https://bugs.kde.org/show_bug.cgi?id=292309

[4] Neovim commit 5fc4c2d442f01ab5
    neovim/neovim@5fc4c2d442f01ab5
    neovim/neovim#3129

[5] Neovim commit 3ccd59ee8216f3da
    neovim/neovim@3ccd59ee8216f3da
    neovim/neovim#6432
    neovim/neovim#6429
    neovim/neovim#6430

[6] https://userbase.kde.org/Konsole/en

[7] Konsole commit 9e3a30fdca2078e0
    https://invent.kde.org/utilities/konsole/-/commit/9e3a30fdca2078e0
    https://bugs.kde.org/show_bug.cgi?id=406955

containers#1449
containers#1696
containers#1698
Copy link
Member

@debarshiray debarshiray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found myself waiting for CI to complete, so I decided to poke at some more of these environment variables.

I included KONSOLE_DBUS_SESSION, KONSOLE_DBUS_WINDOW and KONSOLE_PROFILE_NAME in #1698 because they are mentioned in the Konsole documentation and Neovim uses them.

@debarshiray
Copy link
Member

If toolbox continues to preserve only some environment variables, it might be good to make the list configurable through files in XDG_CONFIG_HOME and XDG_CONFIG_DIRS (thus picking up system defaults in /etx/xdg). This would allow both users and distributions/packages to add variables to the list.

Toolbx has a configuration file. We can add a preserved-environment-variables option to it. Do you want to submit a pull request implementing it? :)

@debarshiray
Copy link
Member

For the record, I have the same setup (Kinoite 42) and I don't have any issue with Qt applications not being properly scaled or themed when running inside Toolbox. I really wonder whether KDE_SESSION_VERSION has any impact on this, I would rather say it's used so others can find out whether you run KDE Plasma 5 or KDE Plasma 6. Still, it won't definitely hurt preserving this env variable, same for KDE_FULL_SESSION.

Thanks a lot for taking a look, @grulja !

debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Aug 7, 2025
A KDE session sets some environment variables to influence the behaviour
of various programs and to access various settings [1].  eg., if the
KDE_SESSION_VERSION environment variable is absent then applications
won't respect KDE's theme or display scaling settings.

These environment variables are not meant to be set by the shell's
start-up scripts, but directly by KDE, and hence needs to be preserved
across the host operating system and Toolbx container.

[1] https://userbase.kde.org/KDE_System_Administration/Environment_Variables

containers#1696
containers#1698
debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Aug 7, 2025
Konsole injects the name of the current profile, and the identifiers
of the current tab and window into the process running inside it
through the KONSOLE_PROFILE_NAME, KONSOLE_DBUS_SESSION and
KONSOLE_DBUS_WINDOW environment variables respectively [1,2,3].  These
are used by programs like Neovim to detect the terminal features
supported by Konsole [4,5], or by users to save the shell's history
separately for each profile, tab or window [6].

These environment variables are not meant to be set by the shell's
start-up scripts, but directly by Konsole, and hence needs to be
preserved across the host operating system and Toolbx container.

Note that KONSOLE_PROFILE_NAME was later removed from Konsole [7].
However, Neovim still uses it, so it's better to preserve it.

[1] Konsole commit debfec2eb3c8ede8
    https://invent.kde.org/utilities/konsole/-/commit/debfec2eb3c8ede8
    https://bugs.kde.org/show_bug.cgi?id=227296

[2] Konsole commit fcd815256c3729f2
    https://invent.kde.org/utilities/konsole/-/commit/fcd815256c3729f2

[3] Konsole commit 07cddfe302233c35
    https://invent.kde.org/utilities/konsole/-/commit/07cddfe302233c35
    https://bugs.kde.org/show_bug.cgi?id=276912
    https://bugs.kde.org/show_bug.cgi?id=281513
    https://bugs.kde.org/show_bug.cgi?id=292309

[4] Neovim commit 5fc4c2d442f01ab5
    neovim/neovim@5fc4c2d442f01ab5
    neovim/neovim#3129

[5] Neovim commit 3ccd59ee8216f3da
    neovim/neovim@3ccd59ee8216f3da
    neovim/neovim#6432
    neovim/neovim#6429
    neovim/neovim#6430

[6] https://userbase.kde.org/Konsole/en

[7] Konsole commit 9e3a30fdca2078e0
    https://invent.kde.org/utilities/konsole/-/commit/9e3a30fdca2078e0
    https://bugs.kde.org/show_bug.cgi?id=406955

containers#1449
containers#1696
containers#1698
@grulja
Copy link

grulja commented Aug 8, 2025

qdbusviewer seems to pick up scaling regardless, but audacious doesn't without the environment variable set. This might have something to do with audacious running through XWayland.

Trying qdbusviewer-qt6 with and without the env variable set produces same styling and everything. Same goes for qdbusviewer-qt6 -platform xcb to enforce XWayland.

Also audacious --qt works for me in sense I don't see a difference between using and not using the KDE_SESSION_VERSION=6. I don't know why it runs with xcb backend (XWayland), but you can enforce it to run natively on Wayland with QT_QPA_PLATFORM=wayland.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants