Subversion Repositories configs

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 - 1
#!/bin/sh
2
 
3
PATH=/sbin:/bin:/usr/bin
4
 
5
# Get the ID of the first active X11 session:
6
uid_session=$(
7
ck-list-sessions | \
8
awk '
9
/^Session[0-9]+:$/ { uid = active = x11 = "" ; next }
10
{ gsub(/'\''/, "", $3) }
11
$1 == "unix-user" { uid = $3 }
12
$1 == "active" { active = $3 }
13
$1 == "x11-display" { x11 = $3 }
14
active == "TRUE" && x11 != "" {
15
	print uid
16
	exit
17
}')
18
 
19
# Check that there is a power manager, otherwise shut down.
20
[ "$uid_session" ] &&
21
ps axo uid,cmd | \
22
awk '
23
    $1 == '$uid_session' &&
24
	($2 ~ /gnome-power-manager/ || $2 ~ /kpowersave/ ||
25
	 $2 ~ /kded4/ || $3 ~ /guidance-power-manager/) \
26
		{ found = 1; exit }
27
    END { exit !found }
28
' ||
29
  shutdown -h now
30