summaryrefslogtreecommitdiffstats
path: root/core/modules/idleaction/data/opt/openslx/scripts/idle-daemon-launcher
blob: 62a919ee8c23a071b8d1cdb78ae5fdad6abe7601 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/ash

. /opt/openslx/config

CMD=

[ -n "$SLX_SHUTDOWN_TIMEOUT" ] && CMD="$CMD --poweroff-timeout $SLX_SHUTDOWN_TIMEOUT"

if [ -n "${SLX_AUTOLOGIN%OFF}" ]; then
	# Autologin is enabled - special case logout timeout, which should turn into
	# a shutdown.
	if [ -n "$SLX_SHUTDOWN_TIMEOUT" ] && [ -n "$SLX_LOGOUT_TIMEOUT" ] && [ "$SLX_SHUTDOWN_TIMEOUT" -gt "$SLX_LOGOUT_TIMEOUT" ]; then
		SLX_LOGOUT_TIMEOUT="$SLX_SHUTDOWN_TIMEOUT"
	fi
	if [ -n "$SLX_LOGOUT_TIMEOUT" ]; then
		CMD="$CMD --logout-is-shutdown"
	fi
fi

if [ -z "${SLX_EXAM}" ]; then
	# Exam mode inactive
	[ -n "$SLX_LOGOUT_TIMEOUT" ] && CMD="$CMD --logout-timeout $SLX_LOGOUT_TIMEOUT"
	[ -n "$SLX_SYSTEM_STANDBY_TIMEOUT" ] && CMD="$CMD --suspend-timeout $SLX_SYSTEM_STANDBY_TIMEOUT"

	# Taken care of by xscreensaver again, as it can now account for ungrab hook messups.
	#[ -n "$SLX_SCREEN_SAVER_TIMEOUT" ] && CMD="$CMD --screensaver-timeout $SLX_SCREEN_SAVER_TIMEOUT"
	#[ -n "$SLX_SCREEN_STANDBY_TIMEOUT" ] && CMD="$CMD --dpms-timeout $SLX_SCREEN_STANDBY_TIMEOUT"
	#[ -n "$SLX_SCREEN_SAVER_GRACE_TIME" ] && CMD="$CMD --grace-period $SLX_SCREEN_SAVER_GRACE_TIME"
else
	# Exam mode active
	CMD="$CMD --min-idle 7200" # Ignore schedule if idle time is lower than 2h
	CMD="$CMD --cmd /opt/openslx/scripts/idle-daemon-trigger-wrapper" # Use wrapper for slxlog
	# Add additional times -- We might miss tightly scheduled ones because of --min-idle
	if [ -n "$SLX_SHUTDOWN_SCHEDULE" ]; then
		SLX_SHUTDOWN_SCHEDULE="$SLX_SHUTDOWN_SCHEDULE 23:00 4:00"
	elif [ -n "$SLX_REBOOT_SCHEDULE" ]; then
		SLX_REBOOT_SCHEDULE="$SLX_REBOOT_SCHEDULE 23:00 4:00"
	fi
fi

for t in $SLX_REBOOT_SCHEDULE; do
	CMD="$CMD --reboot $t"
done
for t in $SLX_SHUTDOWN_SCHEDULE; do
	CMD="$CMD --poweroff $t"
done

if [ "$SLX_ALLOW_USER_BGTASK" != "yes" ]; then
	CMD="$CMD --kill-user-processes"
fi

exec /opt/openslx/sbin/idle-daemon $CMD