Bug 454858

Summary: Autostart > Pre-startup Scripts" shows scripts that startplasma ignores
Product: [Applications] systemsettings Reporter: skierpage <info>
Component: kcm_autostartAssignee: Nicolas Fella <nicolas.fella>
Status: CONFIRMED ---    
Severity: normal CC: 4wy78uwh, kermit, nate, plasma-bugs
Priority: NOR    
Version: 5.24.5   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description skierpage 2022-06-05 03:27:51 UTC
SUMMARY
I disabled an environment variables "script" in $HOME/.config/plasma-workspace/env/ by renaming it `debug_kscreen.sh_HIDE`. That worked, Plasma startup ignored it. But it still shows up in System Settings > Autostart > Pre-startup Scripts, with no indication that it isn't doing anything.

STEPS TO REPRODUCE
1.  Create an environment variables script test.sh in $HOME/.config/plasma-workspace/env/ containing
   export JUNK_TEST=hello
2. Log out of Plasma desktop session and log back in
3. In a terminal, enter `echo $JUNK_TEST`
4. Rename the file test.sh_HIDE
5. Log out of Plasma desktop session and log back in
6. In a terminal, enter `echo $JUNK_TEST`
7. Look in System Settings > Autostart > Pre-startup Scripts

OBSERVED RESULT
The script sets the environment variable `JUNK_TEST` in Plasma to "hello" when it ends in `.sh`, but doesn't if you rename it. That's good, but it still shows up in Pre-startup Scripts (bad).

EXPECTED RESULT
kcm_autostart could implement a "disabled" state (e.g. gray text or a warning icon) for wrong files with a tooltip "File ignored, does not end in .sh". But it's probably simpler to just not show files that do not end with `.sh`.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma:
KDE Plasma Version: 5.24.5
KDE Frameworks Version: 5.93.0
Qt Version: 5.15.3 on Wayland

ADDITIONAL INFORMATION
It seems these .sh files don't need to be executable and don't need a `#!/bin/sh` starting line.
Bug 171136 and bug 286658 seem related.

I think the mismatch happens because startkde/startplasma.cpp runs
    const auto dirScripts = dir.entryInfoList({QStringLiteral("*.sh")}, QDir::Files, QDir::Name);
but kcms/autostart/autostartmodel.cpp runs
    loadScriptsFromDir(QStringLiteral("plasma-workspace/env/"), AutostartModel::AutostartEntrySource::PlasmaEnvScripts);
and doesn't filter/glob on `*.sh`.
Comment 1 Nate Graham 2022-06-07 00:58:13 UTC
Please feel free to submit a merge request to fix it!
Comment 2 David Edmundson 2025-01-10 19:47:20 UTC
*** Bug 391609 has been marked as a duplicate of this bug. ***