Bug 382764 - Save and restore environment variables per application
Summary: Save and restore environment variables per application
Status: RESOLVED INTENTIONAL
Alias: None
Product: ksmserver
Classification: Unmaintained
Component: general (show other bugs)
Version: 5.10.3
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Lubos Lunak
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-26 20:37 UTC by Tristan Miller
Modified: 2019-02-21 13:01 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tristan Miller 2017-07-26 20:37:46 UTC
I sometimes launch applications using different language environment variables, either because I prefer to use that application in a different language from my global defaults, or because I am trying to work around KDE/Qt's lack of support for custom date formats (see the much-hated Bug 340982). For example, I always launch Thunderbird with LC_TIME=en_DK so that it shows me YYYY-MM-DD dates in my message list.

Unfortunately, ksmserver doesn't seem to remember the language environment for these applications when I save the session.  (This problem occurs regardless whether the application was launched from a desktop shortcut or from a shell script that manually sets the environment variable(s).)  For example, when I log out of KDE and log back in again, Thunderbird gets restored, but it formats the dates according to the system default locale rather than en_DK.

It would be useful if ksmserver could somehow recognize when applications are launched with special environment variables, and re-set these variables when restoring the session.  I realize that this may be difficult or impossible to do in the general case, but maybe it is possible at least for applications launched via a standard desktop/menu shortcut.
Comment 1 Lubos Lunak 2017-07-27 10:44:33 UTC
Ksmserver has no reasonable way to find out environment variables of applications. What is possible that applications tell ksmserver which variables to set again, so it would be up to each application to do this. But even than this is very problematic, as applications actually have no good way to known which variables should be restored - how is Thunderbind to know that your LC_TIME is special enough to be kept?

If you launch apps in special ways manually, I'm afraid you'll need to do that manually too. I don't see a reasonable way to do this programatically, sorry.
Comment 2 Dominik Kummer 2019-02-21 13:01:24 UTC
You can exclude your application from ksmserver via system settings > startup and shutdown > desktop sessions.
Later add your application via kmenuedit (right click Application Launcher > edit applications) with environment variable $ env ENV_VAR=true yourapplication --arg;
And finally add the application to system settings > startup and shutdown > autostart > Add Program