What internal command does the KDE autostart mechanism use to start applications?

I’m having a very annoying problem which causes seemingly random applications to start with an orange highlight in the task manager, which visually distracts me until I manually click on them all every time I start my computer.

I start these applications from a PHP CLI script with commands such as: exec('setsid -f krita >/dev/null 2>&1 &');

(setsid -f is used in front to make it “decoupled” from the parent, so that the program doesn’t exit as soon as the script finishes.)

I was told to try the KDE autostart GUI mechanism to see if the same thing happens there. I tried this by uncommenting the Krita line in my script and adding Krita in the autostart GUI setting. This seems to cause Krita to never open with the orange highlight. Weird.

The autogenerated file ~/.config/autostart/org.kde.krita.desktop just says Exec=krita %F in it. I expected something fancy such as kstart --prevent-orange-highlight krita %F.

What to make of this? How can it possibly matter which “thing” is running the same command? Is it actually just running krita %F under the hood? Or does it internally append something in front of it?

No, I can’t use a Bash script or use the KDE autostart mechanism. There are good reasons that this is done from PHP CLI:

  1. My system is in PHP CLI.
  2. It does important things before starting the programs, such as decrypting and mounting drives which the programs need. (No, I can’t use crypttab for this. It locked me out from my machine once and I’m never risking that again.)
  3. They have to be launched in the right order, and logic may have to be done in-between.
  4. Some of them might need custom parameters depending on which day it is, or other dynamic arguments, which my PHP CLI system provides.
  5. I don’t want to yet again be vendor-locked into KDE (or anything else) after being forced to first switch from Windows and then XFCE, which has already caused me untold amounts of suffering.

My point is that it makes no sense that this would only happen just because a PHP CLI script is doing it. It should not matter whatsoever what actually runs the command. I refuse to believe that it does. Surely the KDE autostart mechanism must be running some custom command to prevent this orange highlight annoyance?

The autostart mechanism is implemented in systemd and follows the specification in Desktop Application Autostart Specification

This has the advantage of launching the application in a cgroup which makes it easier for plasma to recognize processes as part of an application. (read more in Bringing modern process management to the desktop – David Edmundson's Web Log)

It seems that it is the main difference in your case.

You can try to use setsid -f kstart5 --application krita >/dev/null 2>&1 & in your script.

Although on the top of my head I can’t tell if it will be sufficient.

1 Like

Thank you. Although --application expects a .desktop file, the almost-similar (but quite difficult to get right!) command setsid -f kstart5 --\!+command krita >/dev/null 2>&1 & works. I’ll have to wait until tomorrow to report whether or not it started all the applications without the orange highlight, though.