Bug 461315 - Kmenuedit should support environment variables
Summary: Kmenuedit should support environment variables
Status: RESOLVED FIXED
Alias: None
Product: kmenuedit
Classification: Applications
Component: general (show other bugs)
Version: 5.26.2
Platform: Arch Linux Linux
: NOR wishlist
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-02 12:34 UTC by Dashon
Modified: 2022-11-09 18:29 UTC (History)
3 users (show)

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


Attachments
Example of working settings in kmenuedit (153.04 KB, image/png)
2022-11-02 12:34 UTC, Dashon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dashon 2022-11-02 12:34:56 UTC
Created attachment 153398 [details]
Example of working settings in kmenuedit

SUMMARY
Sometimes you need to pass in an environment variable on the exec line to an application. The environment variable needs to be appended before the program name on the exec line in the desktop file.


STEPS TO REPRODUCE
1. Edit an application with kmenuedit
2. Try to add an environment variable to command line arguments
3. Save and launch the application.

OBSERVED RESULT
Application will either fail to launch or launch without the environment variable

EXPECTED RESULT
Application should launch with the environment variable passed to the program.

SOFTWARE/OS VERSIONS
Operating System: EndeavourOS
KDE Plasma Version: 5.26.2
KDE Frameworks Version: 5.99.0
Qt Version: 5.15.7
Kernel Version: 6.0.6-zen1-1-zen (64-bit)
Graphics Platform: X11
Processors: 16 × AMD Ryzen 7 5800X 8-Core Processor
Memory: 62.7 GiB of RAM
Graphics Processor: NVIDIA GeForce RTX 3080/PCIe/SSE2
Manufacturer: Micro-Star International Co., Ltd.
Product Name: MS-7C95
System Version: 1.0

ADDITIONAL INFORMATION
I have attached a screenshot of a working example of using kmenuedit to add environment variables to the desktop file. In the example you will see that the program input box contains the name of the environment variable and the command line arguments input box contains the name of the programs and it's command line options. I think there should be one more input box before the program input box that accepts environment variables which must be prepended to the exec line before the program name. Trying to add the environment variable to program input both with the program won't work because kmenuedit will write the environment variable and the program to the exec line surrounded by quotes.

For example:
program: [some-environment-variable=value] [program-name]
will be written to the desktop file like this
exec='[some-environment-variable=value] [program-name]'
the quotation marks won't let the application launch. 
Manually removing the quotation marks from the generated desktop file fixes this.
Hope all this makes sense.
Comment 1 Nate Graham 2022-11-09 17:24:10 UTC
Git commit 6f9126f99f6b6ff8d041447740007ae49be2a5d6 by Nate Graham, on behalf of Dashon Wells.
Committed on 09/11/2022 at 17:24.
Pushed by ngraham into branch 'master'.

Explicitly support environment variables when editing apps' configs

Add explicit support for environment variables in KMenuEdit via a dedicated
text field people can put them in, which will write them into the desktop file
in a functional and standards-compliant manner.

This is a companion change for
https://invent.kde.org/frameworks/kio/-/merge_requests/1025 to keep
kpropertiesdialog and kmenuedit in sync.
FIXED-IN: 5.27

M  +41   -8    basictab.cpp
M  +2    -0    basictab.h

https://invent.kde.org/plasma/kmenuedit/commit/6f9126f99f6b6ff8d041447740007ae49be2a5d6
Comment 2 Nate Graham 2022-11-09 18:29:28 UTC
Git commit cb7bb1278437d239726575e204faa0970b6737d9 by Nate Graham, on behalf of Dashon Wells.
Committed on 09/11/2022 at 18:29.
Pushed by ngraham into branch 'master'.

kpropertiesdialog: Add explicit environment variables support

Add explicit support for environment variables in kpropertiesdialog via a
dedicated text field people can put them in, which will write them into the
desktop file in a functional and standards-compliant manner.

This is a companion change for
https://invent.kde.org/plasma/kmenuedit/-/merge_requests/11 to keep
kpropertiesdialog and kmenuedit in sync.

M  +18   -5    src/widgets/kpropertiesdesktopbase.ui
M  +22   -1    src/widgets/kpropertiesdialog.cpp

https://invent.kde.org/frameworks/kio/commit/cb7bb1278437d239726575e204faa0970b6737d9