Bug 409107 - Allow to run commands with environment variables
Summary: Allow to run commands with environment variables
Status: RESOLVED FIXED
Alias: None
Product: krunner
Classification: Plasma
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Alexander Lohnau
URL:
Keywords:
: 180115 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-06-24 05:27 UTC by Thiago Sueto
Modified: 2020-08-11 07:28 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.20


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thiago Sueto 2019-06-24 05:27:47 UTC
SUMMARY
Often when I need to take screenshots of applications or verify the name of a menu option in English I use LANG=C applicationname.

Typing commands to open applications from the terminal instead of KRunner has two distinct disadvantages: 1) Opening an application from a terminal means opening an application to open another application, unlike Kickoff and KRunner, which are typically already present. 2) Commands (and their corresponding applications) are bound to the terminal, and as such the user needs to either create a new terminal instance for each application or add an & to the end of the command if one doesn't want to keep the terminal open afterwards. KRunner does not have these disadvantages.

It would be fairly convenient and quicker to run commands using environment variables in KRunner.

As for implementation, I think that although not discoverable at all, being able to use environment variables inline (LANG=C applicationname) is very flexible as it would allow to easily and quickly use another environment variable value for each application, whereas being able to set environment variables prior to running commands (similarly to KCron) is pretty discoverable but not as flexible, as it would require going to a specific, dedicated section first in order to change an environment variable, which would be applied to all applications run by KRunner.
Comment 1 Nate Graham 2019-06-24 11:36:25 UTC
I think this makes sense as an advanced feature. I'm kind of surprised that it doesn't just automatically work, in fact.
Comment 2 Alexander Lohnau 2020-07-11 15:24:49 UTC
*** Bug 180115 has been marked as a duplicate of this bug. ***
Comment 3 Bug Janitor Service 2020-07-25 07:18:36 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/172
Comment 4 Alexander Lohnau 2020-08-01 16:12:52 UTC
Git commit 5feeab7560b92a8e4181224d29af69730d59107c by Alexander Lohnau.
Committed on 28/07/2020 at 13:50.
Pushed by dfaure into branch 'master'.

Add overload to invoke terminal with ENV variables

Because this is an exported class we have to add an overload.

M  +18   -3    src/kdeinit/ktoolinvocation.cpp
M  +22   -0    src/kdeinit/ktoolinvocation.h
M  +9    -1    src/kdeinit/ktoolinvocation_win.cpp
M  +9    -1    src/kdeinit/ktoolinvocation_x11.cpp

https://invent.kde.org/frameworks/kservice/commit/5feeab7560b92a8e4181224d29af69730d59107c
Comment 5 Holger 2020-08-02 09:07:36 UTC
I wonder, if this could be related to the broken support of environment variables in *.desktop files? bug 167502 comment #4
Comment 6 Alexander Lohnau 2020-08-02 17:22:01 UTC
IMO it seems not related, because this bug is only about shell commands and not the desktop service stuff.
Comment 7 Alexander Lohnau 2020-08-11 07:28:59 UTC
Git commit dc70225a7c1a373c0db1fe1054ee7048acd95115 by Alexander Lohnau.
Committed on 11/08/2020 at 07:28.
Pushed by alex into branch 'master'.

Allow ENV variables in shell runner
FIXED-IN: 5.20

M  +42   -12   runners/shell/shellrunner.cpp
M  +1    -0    runners/shell/shellrunner.h

https://invent.kde.org/plasma/plasma-workspace/commit/dc70225a7c1a373c0db1fe1054ee7048acd95115