Bug 433362 - Applications started through keyboard shortcuts are not placed in the correct CGroup
Summary: Applications started through keyboard shortcuts are not placed in the correct...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kglobalaccel
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
: 440499 441628 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-02-21 05:57 UTC by Nikos Chantziaras
Modified: 2021-09-03 13:00 UTC (History)
7 users (show)

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


Attachments
Screenshot demontrating the problem. (432.81 KB, image/jpeg)
2021-02-21 05:57 UTC, Nikos Chantziaras
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nikos Chantziaras 2021-02-21 05:57:33 UTC
Created attachment 135996 [details]
Screenshot demontrating the problem.

In System Monitor's "Overview" page, in the "Applications" section, any applications that have been started through a keyboard shortcut are not listed.

STEPS TO REPRODUCE
1. Create an application keyboard shortcut in System Settings->Shortcuts->Applications (see attached screenshot.) For example, I start Firefox with Meta+W and Thunderbird through Meta+M.
2. Start System Monitor.
3. Press the keyboard shortcut that launches the application.

OBSERVED RESULT
The application will be listed in the Overview page.

EXPECTED RESULT
The application should be listed in the Overview page.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Gentoo Linux AMD64
KDE Plasma Version: 5.21
KDE Frameworks Version: 5.79.0
Qt Version: 5.15.2
Comment 1 Arjen Hiemstra 2021-02-22 10:39:52 UTC
Can you provide the output of systemd-cgls? I expect this to actually be a bug in the shortcuts code that doesn't launch the program correctly.
Comment 2 Arjen Hiemstra 2021-02-22 11:50:32 UTC
Apparently this is indeed the case - there's a MR for KGlobalAccel to handle this correctly that was not merged: https://invent.kde.org/frameworks/kglobalaccel/-/merge_requests/3 . In any case, moving this to KGlobalAccel.
Comment 3 David Redondo 2021-08-30 06:49:29 UTC
*** Bug 441628 has been marked as a duplicate of this bug. ***
Comment 4 David Redondo 2021-08-30 13:48:55 UTC
*** Bug 440499 has been marked as a duplicate of this bug. ***
Comment 5 Bug Janitor Service 2021-08-30 13:51:03 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kglobalaccel/-/merge_requests/24
Comment 6 David Redondo 2021-08-30 21:31:36 UTC
Git commit c6c14830a98050cbee5aa48dd8812e2197515de3 by David Redondo.
Committed on 30/08/2021 at 13:45.
Pushed by ngraham into branch 'master'.

Start processes with kstart5 if available

The intention of 717e4ea9f8e9d3f9ea5e6c8de2efbffd5ef2af82 was to start
processes with kstart5 so they are in the correct cgroup. We should
always check if it's available first as we still want to prefer it once
klauncher is registered.

M  +9    -8    src/runtime/kserviceactioncomponent.cpp

https://invent.kde.org/frameworks/kglobalaccel/commit/c6c14830a98050cbee5aa48dd8812e2197515de3
Comment 7 Nikos Chantziaras 2021-08-31 03:39:03 UTC
I applied the patch against 5.85.0 and it works. However, it breaks some applications. For example, I have a "thunderbird.desktop" file in my ~/.local/share/applications directory for launching thunderbird with kdocker (so that I can minimize it to the system tray.) It has this exec line:

Exec=kdocker -d 20 -m -q thunderbird -- %u

If I run kstart5 manually:

$ kstart5 --application thunderbird-bin

it works fine. kstart5 will run it as-is, meaning it runs kdocker and passes it the specified arguments, which in turn runs thunderbird in the system tray.

However, if I try to launch it with a keyboard shortcut, then it doesn't work. The log then shows this error:

kglobalaccel5[2002]: kstart: Unknown options: d, m, q.
Comment 8 Nikos Chantziaras 2021-08-31 03:55:51 UTC
Btw, this is not limited to custom desktop files places in ~/.local. The same happens with everything else. For example, there is:

/usr/share/applications/mpv.desktop

with this in it:

Exec=mpv --player-operation-mode=pseudo-gui -- %U

It's impossible to launch MPV now with a keyboard shortcut. Instead, you get an error:

kglobalaccel5[3721]: kstart: Unknown option 'player-operation-mode'.

So this commit does much more harm than good IMO.
Comment 9 Nate Graham 2021-08-31 14:31:28 UTC
Let's continue that conversation in https://invent.kde.org/frameworks/kglobalaccel/-/merge_requests/24#note_296525
Comment 10 Nate Graham 2021-08-31 15:28:11 UTC
It was reverted pending a better fix; re-opening this.
Comment 11 Nikos Chantziaras 2021-09-02 07:29:00 UTC
(In reply to Nate Graham from comment #10)
> It was reverted pending a better fix; re-opening this.

kstart5 does seem to support "-- ", where everything following it is parsed as part of the command to be executed, not as options to kstart5. For example this works when called from the command line:

  $ kstart5 -- kdocker -d 20 -m -q dolphin

So I tested this and it works:

  if (!kstart.isEmpty()) {
      parts.prepend(command);
      parts.prepend("--");
      QProcess::startDetached(kstart, parts);
Comment 12 Bug Janitor Service 2021-09-02 15:50:40 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kglobalaccel/-/merge_requests/25
Comment 13 Nate Graham 2021-09-03 13:00:32 UTC
Git commit 061c45df933f6a346c85c34fe10df6f1bd857908 by Nate Graham, on behalf of Nikos Chantziaras.
Committed on 02/09/2021 at 15:46.
Pushed by ngraham into branch 'master'.

Fix launching commands with args using kstart5

By prepending "--" to the command, kstart5 parses it all as one thing,
so additional arguments are executed as expected.
FIXED-IN: 5.86

M  +1    -0    src/runtime/kserviceactioncomponent.cpp

https://invent.kde.org/frameworks/kglobalaccel/commit/061c45df933f6a346c85c34fe10df6f1bd857908