Bug 462099 - Autostart of a shell script does not work anymore since the upgrade to 22.04
Summary: Autostart of a shell script does not work anymore since the upgrade to 22.04
Status: RESOLVED UPSTREAM
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_autostart (show other bugs)
Version: 5.26.0
Platform: Neon Linux
: NOR normal
Target Milestone: ---
Assignee: Nicolas Fella
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-21 18:24 UTC by bluelupo
Modified: 2023-01-03 18:33 UTC (History)
5 users (show)

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


Attachments
Screentshot Autostart script in the systemsettings (24.86 KB, image/png)
2022-11-21 18:27 UTC, bluelupo
Details
Autostart shellscript (40 bytes, application/x-shellscript)
2022-11-30 06:34 UTC, bluelupo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bluelupo 2022-11-21 18:24:03 UTC
SUMMARY
***
A short self-made bashscript that starts xbindkeys unfortunately does not work anymore since the update to KDE Neon 22.04. Running the bashscript manually in the console after starting the desktop works without problems.

My Script:
#!/bin/bash
nohup xbindkeys
#EOF

***

Distributor ID:   Neon
Description:   KDE neon 5.26
Release: 22.04
Codename:   jammy

STEPS TO REPRODUCE
1. start from KDE, 
 

OBSERVED RESULT
no process of xbindkeys running

EXPECTED RESULT
An xbindkeys should be visible in the process list

SOFTWARE/OS VERSIONS
Distribution: KDE neon 5.26
Kernel      : 5.15.0-53-generic
Plasma      : 5.26.3
Qt          : 5.15.7
KF          : 5.100.0
Kwin        : 5.18.7



ADDITIONAL INFORMATION
The shell script for the autostart of xbindkeys was correctly included or created by me in the system settings under the item Start and Shutdown, subitem Autostart.
Comment 1 bluelupo 2022-11-21 18:27:48 UTC
Created attachment 153927 [details]
Screentshot Autostart script in the systemsettings
Comment 2 Nate Graham 2022-11-30 00:17:14 UTC
Can you attach the script file?
Comment 3 bluelupo 2022-11-30 06:34:37 UTC
Created attachment 154160 [details]
Autostart shellscript

Here is my shellscript in the file attachment
Comment 4 Nate Graham 2022-11-30 17:35:19 UTC
The script appears to not be executable. Does it start working if you make it executable?
Comment 5 bluelupo 2022-12-01 06:57:46 UTC
the shellccript is executable, I already paid attention to that.

-rwx------ 1 michael michael 24 Feb 10  2015 /home/michael/userscripts/start_xbindkeys
Comment 6 Nate Graham 2022-12-01 20:32:51 UTC
Thanks.

If you run `kwriteconfig5 --file startkderc --group General --key systemdBoot false` in a terminal window and reboot, does it start working again?
Comment 7 bluelupo 2022-12-07 12:53:58 UTC
The command line command they mentioned solved the problem. The start_xbindkeys autostart script is now executed when the KDE desktop is started. Thus the additional key bindings for the mouse are initiated in the script start_xbindkeys .

I still have one question, what exactly does the command do?
Comment 8 Nate Graham 2022-12-07 19:32:16 UTC
It turns off Systemd boot. Systemd boot is stricter about what's allowed to autostart, and it sounds like this thing is triggering its strictness.

You can use that workaround for now, but for further debugging, please disable it by running `kwriteconfig5 --file startkderc --group General --key systemdBoot true`.

David, any ideas?
Comment 9 kskot 2022-12-11 15:04:49 UTC
Might be this bug, which is resolved upstream in systemd 250. Neon is on 249 :(
https://bugs.kde.org/show_bug.cgi?id=433299
Comment 10 thenujan 2022-12-13 04:44:43 UTC
Can you check the logs of the generated autostart unit?
to do so,
cd $XDG_RUNTIME_DIR/systemd/generator.late
You should find the unit generated for your script
then find the logs by systemctl status --user "scriptname"
Comment 11 bluelupo 2022-12-13 07:52:59 UTC
Hi thenujan,

there is no autostart unit

$ systemctl status --user start_xbindkeys.sh
Unit start_xbindkeys.sh.service could not be found.
Comment 12 thenujan 2022-12-13 08:32:49 UTC
(In reply to bluelupo from comment #11)
> Hi thenujan,
> 
> there is no autostart unit
> 
> $ systemctl status --user start_xbindkeys.sh
> Unit start_xbindkeys.sh.service could not be found.

You wouldn't have the autostart unit in the same name. you need to look for the generated unit inside the directory I mentioned ($XDG_RUNTIME_DIR/systemd/generator.late).
It would start with "app-". It would contain the name start_xbindkeys the underscore might be replaced with something else
Comment 13 bluelupo 2022-12-13 08:54:04 UTC
Output of the command....

$ systemctl status --user app-xbindkeys@autostart.serviceapp-xbindkeys@autostart.service - xbindkeys
     Loaded: loaded (/etc/xdg/autostart/xbindkeys.desktop; generated)
     Active: inactive (dead) since Tue 2022-12-13 06:57:21 CET; 2h 49min ago
       Docs: man:systemd-xdg-autostart-generator(8)
    Process: 3105 ExecStart=/usr/bin/xbindkeys_autostart (code=exited, status=0/SUCCESS)
   Main PID: 3105 (code=exited, status=0/SUCCESS)
        CPU: 31ms

Dez 13 06:57:20 neonlight systemd[2614]: Starting xbindkeys...
Dez 13 06:57:20 neonlight systemd[2614]: Started xbindkeys.
Comment 14 bluelupo 2022-12-13 12:08:02 UTC
$ systemctl cat --user app-xbindkeys@autostart.service 
# /run/user/1000/systemd/generator.late/app-xbindkeys@autostart.service
# Automatically generated by systemd-xdg-autostart-generator

[Unit]
Documentation=man:systemd-xdg-autostart-generator(8)
SourcePath=/etc/xdg/autostart/xbindkeys.desktop
PartOf=graphical-session.target

Description=xbindkeys
After=graphical-session.target

[Service]
Type=exec
ExecStart=:/usr/bin/xbindkeys_autostart
Restart=no
TimeoutSec=5s
Slice=app.slice
Comment 15 Nate Graham 2022-12-14 23:57:21 UTC
Looks like it worked. So despite that output, `xbindkeys` is not running? You can confirm with `ps -e | grep -i xbindkeys`?
Comment 16 bluelupo 2022-12-15 06:27:08 UTC
Hello Nate,
no xbindkeys does not run in the process list. 

$ ps -ef|grep -i xbindkeys
michael     8196    8164  0 07:18 pts/1    00:00:00 grep --color=auto -i xbindkeys

$ systemctl status --user app-xbindkeys@autostart.serviceapp-xbindkeys@autostart.service - xbindkeys
     Loaded: loaded (/etc/xdg/autostart/xbindkeys.desktop; generated)
     Active: inactive (dead) since Thu 2022-12-15 06:51:53 CET; 32min ago
       Docs: man:systemd-xdg-autostart-generator(8)
    Process: 3110 ExecStart=/usr/bin/xbindkeys_autostart (code=exited, status=0/SUCCESS)
   Main PID: 3110 (code=exited, status=0/SUCCESS)
        CPU: 28ms

Dez 15 06:51:53 neonlight systemd[2514]: Starting xbindkeys...
Dez 15 06:51:53 neonlight systemd[2514]: Started xbindkeys.
Comment 17 Nate Graham 2022-12-15 19:13:27 UTC
That's odd. It definitely looks like it's running. Maybe it runs and then immediately dies for some reason? This is getting beyond my debugging abilities.
Comment 18 David Edmundson 2022-12-16 13:32:17 UTC
We're missing `ExitType=cgroup`

Newer systemd will fix it.
Comment 19 David Edmundson 2022-12-16 13:44:38 UTC
As a workaround, wrapping in a shell script would work as then the topmost process will stay alive
Comment 20 Nate Graham 2023-01-03 18:33:06 UTC
This bug was filed against Neon, which uses Ubuntu 22.04 as a base. It's not that old, so it's unfortunate that they don't ship the version of systemd with this bug fixed.

What systemd version is the fix in?