From: | "Samuli Suominen (ssuominen)" <ssuominen@g.o> |
---|---|
To: | gentoo-commits@l.g.o |
Subject: | [gentoo-commits] gentoo-x86 commit in sys-power/acpid/files: acpid-2.0.4-powerbtn.sh |
Date: | Wed, 28 Apr 2010 15:21:12 |
Message-Id: | 20100428152108.2E99D2C065@corvid.gentoo.org |
1 | ssuominen 10/04/28 15:21:08 |
2 | |
3 | Added: acpid-2.0.4-powerbtn.sh |
4 | Log: |
5 | New powerbtn.sh (power button script forked from fedora) wrt #317421. |
6 | (Portage version: 2.2_rc67/cvs/Linux x86_64) |
7 | |
8 | Revision Changes Path |
9 | 1.1 sys-power/acpid/files/acpid-2.0.4-powerbtn.sh |
10 | |
11 | file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-power/acpid/files/acpid-2.0.4-powerbtn.sh?rev=1.1&view=markup |
12 | plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-power/acpid/files/acpid-2.0.4-powerbtn.sh?rev=1.1&content-type=text/plain |
13 | |
14 | Index: acpid-2.0.4-powerbtn.sh |
15 | =================================================================== |
16 | #!/bin/sh |
17 | |
18 | PATH=/sbin:/bin:/usr/bin |
19 | |
20 | # Get the ID of the first active X11 session: |
21 | uid_session=$( |
22 | ck-list-sessions | \ |
23 | awk ' |
24 | /^Session[0-9]+:$/ { uid = active = x11 = "" ; next } |
25 | { gsub(/'\''/, "", $3) } |
26 | $1 == "unix-user" { uid = $3 } |
27 | $1 == "active" { active = $3 } |
28 | $1 == "x11-display" { x11 = $3 } |
29 | active == "TRUE" && x11 != "" { |
30 | print uid |
31 | exit |
32 | }') |
33 | |
34 | # Check that there is a power manager, otherwise shut down. |
35 | [ "$uid_session" ] && |
36 | ps axo uid,cmd | \ |
37 | awk ' |
38 | $1 == '$uid_session' && |
39 | ($2 ~ /gnome-power-manager/ || $2 ~ /kded4/ || |
40 | $3 ~ /kded4/ || $3 ~ /guidance-power-manager/) \ |
41 | { found = 1; exit } |
42 | END { exit !found } |
43 | ' || |
44 | shutdown -h now |