File: run-systemd-session

package info (click to toggle)
xfce4-session 4.20.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,592 kB
  • sloc: ansic: 29,692; sh: 5,791; makefile: 499; xml: 266; sed: 16
file content (22 lines) | stat: -rwxr-xr-x 929 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh
set -e

# robustness: if the previous graphical session left some failed units,
# reset them so that they don't break this startup
for unit in $(systemctl --user --no-legend --state=failed list-units | cut -f1 -d' '); do
if [ "$(systemctl --user show -p PartOf --value)" = "graphical-session.target" ]; then
    systemctl --user reset-failed $unit
fi
done

systemctl --user restart graphical-session-pre.target
systemctl --user restart "$1"

# Wait until the session gets closed
# FIXME: replace with an event-based waiting instead of polling (needs new systemctl functionality)
while systemctl --user --quiet is-active "$1"; do sleep 1; done

# Delay killing the X server until all graphical units stopped
# FIXME: we currently cannot make targets wait on its dependencies going to
# "inactive", only to "deactivating"
while [ -n "$(systemctl --user --no-legend --state=deactivating list-units)" ]; do sleep 0.2; done