Bug 456474 - Autostart Application broken if app command contains env variable override
Summary: Autostart Application broken if app command contains env variable override
Status: RESOLVED NOT A BUG
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_autostart (show other bugs)
Version: 5.25.2
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Nicolas Fella
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-08 06:51 UTC by Andrea Ippolito
Modified: 2022-07-12 12:44 UTC (History)
2 users (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 Andrea Ippolito 2022-07-08 06:51:33 UTC
SUMMARY
When adding an autostart entry of type "Application", if the application's .desktop file contains env variable override(s), then autostart won't happen.

STEPS TO REPRODUCE
1. Change firefox's default command (at least the default on opensuse TW) from `firefox %u` to `MOZ_DISABLE_RDD_SANDBOX=1 firefox %u` (this is a hack I have to use until Firefox 102 comes out for my distro)
2. add an auto-start entry of type Application, search for firefox in the list and confirm
3. reboot PC/restart session

OBSERVED RESULT
Firefox not auto-starting

EXPECTED RESULT
Firefox auto-starts

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20220706
KDE Plasma Version: 5.25.2
KDE Frameworks Version: 5.95.0
Qt Version: 5.15.5
Kernel Version: 5.18.9-1-default (64-bit)
Graphics Platform: Wayland
Processors: 8 × 11th Gen Intel® Core™ i7-1165G7 @ 2.80GHz
Memory: 15,4 GiB of RAM
Graphics Processor: Mesa Intel® Xe Graphics
Manufacturer: Dell Inc.
Product Name: XPS 13 9305

ADDITIONAL INFORMATION
The same happens with insync, which doesn't properly handle Wayland: its tray icon is not displayed under a Wayland session. To make it appear, insync tech support advised to launch the app with:

QT_QPA_PLATFORM=xcb insync start

And here again I face the same issue, no auto-start. As soon as I remove QT_QPA_PLATFORM=xcb, the app auto-starts (no tray icon tho, but I could confirm by checking running processes)
Comment 1 David Edmundson 2022-07-08 07:37:12 UTC
>1. Change firefox's default command (at least the default on opensuse TW) from `firefox %u` to `MOZ_DISABLE_RDD_SANDBOX=1 firefox %u` (this is a hack I have to use until Firefox 102 comes out for my distro)

That's an invalid desktop file as per the spec.

Exec=env MOZ_DISABLE_RDD_SANDBOX=1 firefox %u

would be valid.
Comment 2 Andrea Ippolito 2022-07-08 08:38:26 UTC
(In reply to David Edmundson from comment #1)
> >1. Change firefox's default command (at least the default on opensuse TW) from `firefox %u` to `MOZ_DISABLE_RDD_SANDBOX=1 firefox %u` (this is a hack I have to use until Firefox 102 comes out for my distro)
> 
> That's an invalid desktop file as per the spec.
> 
> Exec=env MOZ_DISABLE_RDD_SANDBOX=1 firefox %u
> 
> would be valid.

Hello David,

thanks for your reply, but unfortunately the suggested fix still doesn't provide the expected behavior:

https://imgur.com/a/Aui5tdJ
Comment 3 David Edmundson 2022-07-08 10:32:50 UTC
Drop the "Exec=" at the front.

I was speaking in terms of what we see if we edit the file by hand not the UI.
Comment 4 Andrea Ippolito 2022-07-12 12:44:39 UTC
(In reply to David Edmundson from comment #3)
> Drop the "Exec=" at the front.
> 
> I was speaking in terms of what we see if we edit the file by hand not the
> UI.

Hello,
indeed it works if I drop the Exec= part, so thanks for that.
However, I find it a bit misleading for a desktop file to allow to launch an app with, for example:
MOZ_DISABLE_RDD_SANDBOX=1 firefox (so, without the "env" prefix)

Whereas such "env" prefix becomes mandatory the moment you want to autostart an app.

Is this expected/is there's a reason for that?

If autostart enforces such a strict behavior, maybe application launching should also expect "env", or refuse to launch the app with an error, for example. What do you think?