Bug 356190 - scripts in $HOME/.config/plasma-workspace/shutdown not executed at full shutdown
Summary: scripts in $HOME/.config/plasma-workspace/shutdown not executed at full shutdown
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: general (show other bugs)
Version: 5.4.3
Platform: openSUSE Linux
: NOR normal
Target Milestone: 1.0
Assignee: David Edmundson
URL:
Keywords:
: 356898 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-12-02 10:52 UTC by dutchkind
Modified: 2015-12-20 21:01 UTC (History)
4 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 dutchkind 2015-12-02 10:52:59 UTC
I have several scripts in $HOME/.config/plasma-workspace/shutdown to do some cleanup and prevent data corruption of my home file system (encrypted) but those scripts are only executed when I log out of the session. They are not executed when doing a full shutdown or reboot.

Reproducible: Always

Steps to Reproduce:
1. Reboot or shutdown
2. 
3.

Actual Results:  
Nothing executed in $HOME/.config/plasma-workspace/shutdown

Expected Results:  
All scripts in $HOME/.config/plasma-workspace/shutdown should be executed and finished before completing the shutdown/reboot

As mentioned, I use an encrypted home, and if some processes are left running, infamously being kactivitymanagerd, I end up with corrupted files because of dirty unmounts. Besides scripts to fix that I have some other things to run before shutdown.

If this should be handled by systemd, any suggestion on how to do that is appreciated, I did try several ways with systemd to no avail
Comment 1 Marco Martin 2015-12-03 12:49:05 UTC
ksmserver issue?
Comment 2 David Edmundson 2015-12-03 23:59:07 UTC
Shutdown scripts are done by startkde after ksmserver quits.

Which never happens because we've told systemd to shutdown. Older systems asked the DM to close us then they did the shutting down (because you need something that runs as root to do it)

Obvious fix is to just move shutdown scripts into ksmserver before we call KDisplayManager::shutdown (which weirdly includes logout) and remove code from startkde. I'll do that tomorrow for 5.5.1

A more awesome (but less portable) method is to make ksmserver have a systemd delay inhibitor on shutdown; but then we'd need a separate path for logout...so maybe not worth it
Comment 3 dutchkind 2015-12-06 10:18:57 UTC
Would be great if this gets fixed! There is probably no hope to see this backported to older versions? Otherwise it will probably take another year before this fix would reach opensuse :(
Comment 4 David Edmundson 2015-12-13 16:29:52 UTC
Git commit 1dc7f11692a4096b9815ae24f7be9cec10f8f7a5 by David Edmundson.
Committed on 13/12/2015 at 16:29.
Pushed by davidedmundson into branch 'Plasma/5.5'.

Move shutdown scripts into ksmserver cleanup

Shutdown scripts are done by startkde after ksmserver quits. Which never
happens because we've told systemd to shutdown.

Old systems worked because they used to communicate with the display
manager which then closed us before shutting down, this is no longer the
case.

This moves handling the shutdown scripts into ksmserver (which already
handles startup scripts) and runs them before asking logind to shutdown.
REVIEW: 126268

M  +27   -0    ksmserver/server.cpp
M  +2    -0    ksmserver/server.h
M  +0    -9    startkde/startkde.cmake
M  +0    -9    startkde/startplasma.cmake

http://commits.kde.org/plasma-workspace/1dc7f11692a4096b9815ae24f7be9cec10f8f7a5
Comment 5 David Edmundson 2015-12-20 21:01:14 UTC
*** Bug 356898 has been marked as a duplicate of this bug. ***