Bug 391609 - Warn about invalid autostart scripts
Summary: Warn about invalid autostart scripts
Status: ASSIGNED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_autostart (show other bugs)
Version: unspecified
Platform: Neon Linux
: NOR wishlist
Target Milestone: ---
Assignee: Lubos Lunak
URL:
Keywords: usability
Depends on:
Blocks:
 
Reported: 2018-03-09 13:21 UTC by Arek Guzinski
Modified: 2023-08-14 15:33 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arek Guzinski 2018-03-09 13:21:54 UTC
I have an autostart script configured in KDE.

In "System Settings" -> Startup and Shutdown" -> "Autostart"

Name          Command       Status     Run On
Script File
| myxinit.sh  myxinit.sh    Enabled    Startup
| noblink.sh  noblink.sh    Enabled    Before session start-up


.xsession-errors has the line
ksmserver: Starting autostart script  "/home/arek/.config/autostart-scripts/myxinit.sh"
but nothing about noblink.sh

however myxinit.sh is not executed (tested by putting "touch /tmp/yes" at the beginning. The file is not created)

the code in noblink.sh is executed as expected
Comment 1 Arek Guzinski 2018-04-03 08:20:56 UTC
i experimented with running myxinit.sh from noblink.sh as a workaround and discovered that noblink.sh is executed twice at login and once at logout (i expected it to run only once at login). Is this wanted behaviour or another (possibly related) bug?
Comment 2 francisco_t 2018-04-25 18:02:44 UTC
I have a "command" in autostart. It's a .desktop file:

[Desktop Entry]
Comment[es_ES]=
Comment=
Exec=xmodmap ~/.xmodmaprc
GenericName[es_ES]=
GenericName=
Icon=system-run
MimeType=
Name[es_ES]=
Name=
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=

And doesn't work too in 5.12.x
Comment 3 Arek Guzinski 2018-06-19 08:18:53 UTC
okay...
I just tried this with KUbuntu 18.04 LTS in VirtualBox and autostart works fine there.
So maybe this will be fixed when Neon finally switches to 18.04.
Upgrading to 5.13 on Neon at least, did not change anything... :(
The question is: do i want to wait that long? It's really annoying to start all the stuff manually on login.

Are there any known workarounds?

If not, is there a guide on how to run ksmserver in gdb?
I imagine it's not simple, as it should start a clean X/Wayland session.
Comment 4 Alexander Mentyu 2018-07-03 14:16:06 UTC
Cannot reproduce, autostart script is always starting

echo '123' >> /home/user/123

Maybe there are some particularities in the script that are causing the problem?

Plasma: 5.13.2
Apps: 18.04.2
Frameworks: 5.47.0
Qt: 5.11.1
Kernel: 4.18.0-1-MANJARO
OS: Netrunner Rolling
Video: Intel 4400
Driver: xf86-video-intel 1:2.99.917+831+ge7bfc906-1
Mesa 3D: 18.1.3
Screen: 1600x900
Xorg: 1.20
Wayland: 1.15.0-1
Wayland Protocols: 1.14-1
Comment 5 Arek Guzinski 2018-07-04 11:41:06 UTC
> Maybe there are some particularities in the script that are causing the problem?

damn it!

yes, actually there was something.. 

after some more experimenting, i found that the "Session Autostart Manager Control Panel Module" -> "Add Script" was adding the
"#!/bin/sh
"
header to every script, which seems to be mandatory now...

since my script was from the old days, it did not have that header.
adding it, fixed this problem :)

would be nice if kde would have told me, my script can't start because of that.
maybe "Session Autostart Manager Control Panel Module" could make a quick check when it's opened?


the multiple execution issue with scripts that run "Before session start-up" still remains. should i open another bug for that?


@Alexander Mentyu: thanks for motivating me to look closer!

@francisco_t: many of the things xmodmap does, would be overwritten when kde sets the keyboard layout. are you sure that's not happening? (i don't think it should, but.. maybe..)
as a workaround, you could try a script with the line
(sleep 5; xmodmap ~/.xmodmaprc)&
Comment 6 francisco_t 2018-07-05 21:42:22 UTC
(In reply to Arek Guzinski from comment #5)
> 
> @francisco_t: many of the things xmodmap does, would be overwritten when kde
> sets the keyboard layout. are you sure that's not happening? (i don't think
> it should, but.. maybe..)
> as a workaround, you could try a script with the line
> (sleep 5; xmodmap ~/.xmodmaprc)&

It's working! Thanks!
Comment 7 Méven Car 2020-06-03 07:17:30 UTC
A shell script is a shell script when it starts with "#!/bin/sh" or "#!/bin/bash"..

The autostart kcm should show a warning when the file is text and its content does not start with "#!/bin/" or has not the executable rights to prevent such issues.
Comment 8 Nate Graham 2022-07-01 16:37:31 UTC
Git commit 9bad434fbf94b1398056fafd8caf49a371ea6140 by Nate Graham, on behalf of Nicolas Fella.
Committed on 01/07/2022 at 16:37.
Pushed by ngraham into branch 'master'.

kcms/autostart: Warn when adding a non-executable script and offer to fix it

The login/logout script files need to be executable. To avoid the user
wondering why their script isn't executing, warn them if the file is not
executable and offer to fix it.

M  +13   -0    kcms/autostart/autostartmodel.cpp
M  +2    -0    kcms/autostart/autostartmodel.h
M  +28   -1    kcms/autostart/package/contents/ui/main.qml

https://invent.kde.org/plasma/plasma-workspace/commit/9bad434fbf94b1398056fafd8caf49a371ea6140
Comment 9 Bug Janitor Service 2023-07-25 14:25:09 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/3108
Comment 10 Nate Graham 2023-08-14 15:33:21 UTC
Git commit e54bd896ce1e8daaeb29b67d6e40c95ec83c5db5 by Nate Graham, on behalf of Thenujan Sandramohan.
Committed on 14/08/2023 at 17:33.
Pushed by ngraham into branch 'master'.

kcms/autostart: Show more info about systemd-backed entries

This MR gets info about autostart systemd units using dbus and shows them
on a new sub-page in the KCM. This will make it easy for people to figure
out why their autostart entries aren't autostarting or debug other issues.
Related: bug 401536, bug 455889
FIXED-IN: 6.0

M  +3    -1    CMakeLists.txt
M  +17   -2    kcms/autostart/CMakeLists.txt
M  +2    -1    kcms/autostart/autostart.cpp
M  +61   -4    kcms/autostart/autostartmodel.cpp
M  +17   -0    kcms/autostart/autostartmodel.h
A  +127  -0    kcms/autostart/ui/entry.qml     [License: GPL(v2.0+)]
M  +107  -52   kcms/autostart/ui/main.qml
A  +249  -0    kcms/autostart/unit.cpp     [License: GPL(v2.0+)]
A  +64   -0    kcms/autostart/unit.h     [License: GPL(v2.0+)]

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