From: Mirko Günther <renegart@gmx.de>
Subject: lomiri-greeter-wrapper: stop session units when terminated

LightDM ends the greeter with SIGTERM. The trap handler then only kills
Lomiri and exits, so stopping lomiri-keyboard.service and
lomiri-indicators.target after `wait` is never reached. The keyboard keeps
running in the greeter's user manager, loses its compositor and is
restarted by Restart=on-failure while no Wayland socket exists, aborting
with a core dump each time.

Stop the units in the trap handler, which also runs on normal exit, and
stop the keyboard before Lomiri goes away.

--- a/data/lomiri-greeter-wrapper
+++ b/data/lomiri-greeter-wrapper
@@ -26,9 +26,11 @@
 cleanup()
 {
     trap - TERM EXIT
+    systemctl --user stop lomiri-keyboard.service
     if [ -n "$CMD_PID" ]; then
         kill "$CMD_PID"
     fi
+    systemctl --user stop lomiri-indicators.target
     exit 0
 }
 
@@ -94,6 +96,3 @@
 
 wait $CMD_PID
 CMD_PID=
-
-systemctl --user stop lomiri-keyboard.service
-systemctl --user stop lomiri-indicators.target
