public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo-x86 commit in sys-power/acpid/files: acpid-2.0.4-powerbtn.sh
@ 2010-04-28 15:21 Samuli Suominen (ssuominen)
  0 siblings, 0 replies; only message in thread
From: Samuli Suominen (ssuominen) @ 2010-04-28 15:21 UTC (permalink / raw
  To: gentoo-commits

ssuominen    10/04/28 15:21:08

  Added:                acpid-2.0.4-powerbtn.sh
  Log:
  New powerbtn.sh (power button script forked from fedora) wrt #317421.
  (Portage version: 2.2_rc67/cvs/Linux x86_64)

Revision  Changes    Path
1.1                  sys-power/acpid/files/acpid-2.0.4-powerbtn.sh

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-power/acpid/files/acpid-2.0.4-powerbtn.sh?rev=1.1&view=markup
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

Index: acpid-2.0.4-powerbtn.sh
===================================================================
#!/bin/sh

PATH=/sbin:/bin:/usr/bin

# Get the ID of the first active X11 session:
uid_session=$(
ck-list-sessions | \
awk '
/^Session[0-9]+:$/ { uid = active = x11 = "" ; next }
{ gsub(/'\''/, "", $3) }
$1 == "unix-user" { uid = $3 }
$1 == "active" { active = $3 }
$1 == "x11-display" { x11 = $3 }
active == "TRUE" && x11 != "" {
	print uid
	exit
}')

# Check that there is a power manager, otherwise shut down.
[ "$uid_session" ] &&
ps axo uid,cmd | \
awk '
    $1 == '$uid_session' &&
	($2 ~ /gnome-power-manager/ || $2 ~ /kded4/ ||
	 $3 ~ /kded4/ || $3 ~ /guidance-power-manager/) \
		{ found = 1; exit }
    END { exit !found }
' ||
  shutdown -h now







^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-04-28 15:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-28 15:21 [gentoo-commits] gentoo-x86 commit in sys-power/acpid/files: acpid-2.0.4-powerbtn.sh Samuli Suominen (ssuominen)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox