OBS User unknown 2008-08-18 16:16:56 +00:00 committed by Git OBS Bridge
parent 4f76b7aa63
commit d1ef30a566
5 changed files with 84 additions and 5 deletions

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu Aug 7 23:03:40 CEST 2008 - hmacht@suse.de
- add power_button script to care about button presses if there
is no active X session
-------------------------------------------------------------------
Sun Jun 8 18:01:52 CEST 2008 - hmacht@suse.de

View File

@ -2,9 +2,16 @@
# spec file for package acpid (Version 1.0.6)
#
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
@ -14,7 +21,7 @@
Name: acpid
Url: http://acpid.sourceforge.net/
Version: 1.0.6
Release: 65
Release: 76
%define acpi_version 0.09
License: GPL v2 or later
Group: System/Daemons
@ -29,6 +36,7 @@ Source3: README.SuSE
Source4: thinkpad_acpi.modprobe
Source5: events.default
Source6: thinkpad_handler
Source7: power_button
Patch1: acpi_%{acpi_version}.dif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
ExclusiveArch: %ix86 x86_64 ia64
@ -55,7 +63,7 @@ Authors:
%patch1
pushd acpi-%{acpi_version}
popd
cp %{S:2} %{S:3} %{S:4} %{S:5} %{S:6} .
cp %{S:2} %{S:3} %{S:4} %{S:5} %{S:6} %{S:7} .
%build
make EXTRA_CFLAGS="$RPM_OPT_FLAGS -DUSE_SYSLOG"
@ -70,6 +78,7 @@ make install INSTPREFIX=%{buildroot} SBINDIR=%{buildroot}/sbin
install -Dm 744 rcacpid %{buildroot}/etc/init.d/acpid
install -Dm 644 thinkpad_acpi.modprobe %{buildroot}/etc/modprobe.d/thinkpad_acpi
install -Dm 744 thinkpad_handler %{buildroot}/usr/lib/acpid/thinkpad_handler
install -Dm 744 power_button %{buildroot}/usr/lib/acpid/power_button
mkdir -p %{buildroot}/usr/sbin
ln -sf ../../etc/init.d/acpid %{buildroot}/usr/sbin/rcacpid
install -Dm 644 events.default %{buildroot}/etc/acpi/events/default
@ -117,6 +126,9 @@ rm -rf %{buildroot}
%ghost %config(noreplace,missingok) %_var/log/acpid
%changelog
* Fri Aug 08 2008 hmacht@suse.de
- add power_button script to care about button presses if there
is no active X session
* Sun Jun 08 2008 hmacht@suse.de
- minor fixes to the thinkpad_handler script (bnc#371927)
* Fri Jun 06 2008 hmacht@suse.de

View File

@ -2,3 +2,6 @@
event=ibm/.*
action=/usr/lib/acpid/thinkpad_handler "%e"
event=button/power.*
action=/usr/lib/acpid/power_button

58
power_button Normal file
View File

@ -0,0 +1,58 @@
#!/bin/bash
#
# check if a X session is running and active.
# If not, shut down the system
#
# Copyright (C) 2008 Holger Macht <hmacht@suse.de>
#
# This file is released under the GPLv2.
#
EXEC="/sbin/shutdown -h now"
# check if we have pm-profiler and an active profile. If so, $EXEC can be
# overwritten by the active profile's configuration
. /etc/pm-profiler.conf > /dev/null 2>&1
if [ "$?" = "0" ]; then
. /etc/pm-profiler/$PM_PROFILER_PROFILE/config >/dev/null 2>&1
fi
[ -z "$POWER_BUTTON_HOOK" ] || EXEC="$POWER_BUTTON_HOOK"
# iterate over all sessions. If a active X session is found, do nothing
while read A; do
SESSION=`echo $A | sed 's/\(Session[0-9]*\)://g'`
[ -z "$SESSION" ] || continue
SESSION=`echo $A | sed 's/\(Session[0-9]*\):/\1/g'`
IS_X=`dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit \
/org/freedesktop/ConsoleKit/$SESSION \
org.freedesktop.ConsoleKit.Session.GetX11Display`
# check if this is a X session, if not, go on
DISP=`echo $IS_X | sed -e 's/^.* string "\(.*\)"/\1/'`
[ -n "$DISP" ] || continue
IS_ACTIVE=`dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit \
/org/freedesktop/ConsoleKit/$SESSION \
org.freedesktop.ConsoleKit.Session.IsActive`
IS_ACTIVE=`echo $IS_ACTIVE | sed -e 's/^.* boolean \(.*\)$/\1/'`
# debug
#if [ "$IS_ACTIVE" = "true" ]; then
# echo "and is active"
#else
# echo "and is not active"
#fi
if [ "$IS_ACTIVE" = "true" -a -n "$DISP" ]; then
# additional check, if none of these two apps are running, go on
if [ -n "`pidof kpowersave`" -o -n "`pidof gnome-power-manager`" ]; then
echo doing nothing...
exit 0
fi
fi
done < <(ck-list-sessions)
logger -s -t pm-profiler "Power Button pressed, executing $EXEC"
$EXEC

View File

@ -14,7 +14,7 @@
### BEGIN INIT INFO
# Provides: acpid
# Required-Start: $local_fs
# Required-Stop:
# Required-Stop: $null
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Short-Description: Listen and dispatch ACPI events from the kernel