blob: 4172d8dab19ace83a6423ba2022f14481fde5aea (
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#!/bin/ash
DPMS=False
if which xscreensaver; then
secsToTime() {
local NUM SECS MINS HRS
NUM="$1"
SECS=0$(( NUM % 60 ))
MINS=0$(( ( NUM / 60 ) % 60 ))
HRS=0$(( ( NUM / 3600 ) % 60 ))
echo "${HRS:$(( ${#HRS} - 2 )):2}:${MINS:$(( ${#MINS} - 2 )):2}:${SECS:$(( ${#SECS} - 2 )):2}"
}
[ -z "$UID" ] && UID=$(id -u)
[ -z "$HOME" ] && HOME="$(getent passwd "$UID" | head -n 1 | awk -F ':' '{print $6}')"
. /opt/openslx/config
SBY=${SLX_SCREEN_STANDBY_TIMEOUT}
if [ -n "${SLX_EXAM}" ]; then
SLX_LOGOUT_TIMEOUT=0
SBY=0
elif [ -z "$SBY" ]; then
SBY=0
elif [ "$SBY" -gt 0 ] && [ "$SBY" -lt 60 ]; then
SBY=60
elif ! [ "$SBY" -ge 0 ]; then # isNumeric?
SBY=0
fi
# Make sure standby timeout is less than logout timeout, otherwise, disable standby
if [ "$SBY" -gt 0 ]; then
if [ "$SLX_LOGOUT_TIMEOUT" -gt 0 ]; then
if [ "$SBY" -lt 300 ]; then
SBY=300
fi
if [ "$SLX_LOGOUT_TIMEOUT" -lt "$SBY" ]; then
SBY=0
fi
fi
fi
# Create config value for standby timeout
[ "$SBY" -gt 0 ] && DPMS=True
STANDBY="$( secsToTime "$SBY" )"
if [ -z "$SLX_SCREEN_SAVER_TIMEOUT" ]; then
# Create config for screensaver activation timeout
if [ "$SLX_LOGOUT_TIMEOUT" -gt 0 ] && [ "$SBY" -eq 0 ]; then
# Standby is disabled, consider logout timeout
TMO=$SLX_LOGOUT_TIMEOUT
else
# Consider standby timeout
TMO=$SBY
fi
# Start screen saver 3 minutes before forced logout, or screen enters standby
TMO=$(( TMO - 180 ))
if [ "$TMO" -gt 0 ]; then
[ "$TMO" -gt 1200 ] && TMO=$(( TMO - 300 ))
TIMEOUT="$( secsToTime "$TMO" )"
else
TIMEOUT="99:00:00"
fi
else
# Explicit screen saver timeout set
TIMEOUT="$( secsToTime "$SLX_SCREEN_SAVER_TIMEOUT" )"
fi
if [ -z "$SLX_SCREEN_SAVER_GRACE_TIME" ]; then
GRACE="00:00:15"
else
GRACE="$( secsToTime "$SLX_SCREEN_SAVER_GRACE_TIME" )"
fi
if ! [ -s "$HOME/.xscreensaver" ]; then
cat > "$HOME/.xscreensaver" <<EOF
mode: one
cycle: 99:00:00
timeout: $TIMEOUT
lock: True
lockTimeout: $GRACE
fade: False
unfade: False
dpmsEnabled: $DPMS
dpmsStandby: $STANDBY
dpmsSuspend: $STANDBY
dpmsOff: $STANDBY
dpmsFullThrottle: True
newLoginCommand:
externalUngrabCommand: /opt/openslx/xscreensaver/ungrab
programs: /opt/openslx/bin/bwlp-screensaver
selected: 0
EOF
fi
xscreensaver -no-splash &
fi
true
|