[Pkg-acpi-devel] Bug#919942: acpi-support: don't handle lid and power events if elogind is also active

Mark Hindley mark at hindley.org.uk
Sun Jan 20 21:31:25 GMT 2019


On Sun, Jan 20, 2019 at 08:37:15PM +0100, Michael Meskes wrote:
> > So I think this aspect of this bug should be reassigned to acpi-
> > support. I will
> > try and prepare a patch and then clone the bug. acpi-support
> > maintainers, are
> > you OK with that?
> 
> Sure. Thanks.

Michael

Thanks very much.

A quick summary:

acpi-support and elogind should not to attempt to manage the same events (lid,
power button, shutdown and suspend). acpi-support already detects systemd and
cedes control of these to it. Support for this could helpfully be extended to
elogind.

I have prepared a suggested patch which is based on the following premises:

 - systemd-shim is no longer in the repository
 - testing for an org.freedesktop.login1.Manager method should be successful for
   systemd, elogind or any future logind implementation.
 - rename the function to reflect its new purpose. 

Mark

diff --git a/debian/addons/lib/policy-funcs b/debian/addons/lib/policy-funcs
index 4214175..9302c12 100644
--- a/debian/addons/lib/policy-funcs
+++ b/debian/addons/lib/policy-funcs
@@ -45,16 +45,14 @@ DBusSend() {
 	fi
 }
 
-# Check if systemd-logind will be able to call org.freedesktop.systemd1.Manager
-# interface provided by systemd running as PID 1 or by systemd-shim
-HasLogindAndSystemd1Manager() {
-  pidof -x "/lib/systemd/systemd-logind" > /dev/null &&
+# Check if org.freedesktop.login1.Manager interface is available
+HasDBusLogin1() {
   test -x /usr/bin/dbus-send &&
-  # shutdown.target used as a representative of power management calls class
+  # CanHalt used as a representative of login1 methods
   dbus-send --print-reply --system --type=method_call \
-    --dest=org.freedesktop.systemd1 \
-    /org/freedesktop/systemd1 \
-    org.freedesktop.systemd1.Manager.GetUnitFileState string:shutdown.target \
+    --dest=org.freedesktop.login1 \
+    /org/freedesktop/login1 \
+    org.freedesktop.login1.Manager.CanHalt \
     > /dev/null 2>&1
 }
 
diff --git a/debian/addons/scripts/lid.sh b/debian/addons/scripts/lid.sh
index 600f5d1..7dc507b 100644
--- a/debian/addons/scripts/lid.sh
+++ b/debian/addons/scripts/lid.sh
@@ -8,7 +8,7 @@ test -f /usr/share/acpi-support/state-funcs || exit 0
 
 [ -x /etc/acpi/local/lid.sh.pre ] && /etc/acpi/local/lid.sh.pre
 
-if { CheckPolicy || HasLogindAndSystemd1Manager; }; then
+if { CheckPolicy || HasDBusLogin1; }; then
 	exit
 fi
 
diff --git a/debian/addons/scripts/powerbtn-acpi-support.sh b/debian/addons/scripts/powerbtn-acpi-support.sh
index ec66597..7c8723e 100644
--- a/debian/addons/scripts/powerbtn-acpi-support.sh
+++ b/debian/addons/scripts/powerbtn-acpi-support.sh
@@ -15,7 +15,7 @@ fi
 
 . /usr/share/acpi-support/policy-funcs
 
-if { CheckPolicy || HasLogindAndSystemd1Manager; }; then
+if { CheckPolicy || HasDBusLogin1; }; then
 	exit 0
 fi
 
diff --git a/debian/addons/scripts/sleep_suspend.sh b/debian/addons/scripts/sleep_suspend.sh
index 71152e6..6beb3b8 100644
--- a/debian/addons/scripts/sleep_suspend.sh
+++ b/debian/addons/scripts/sleep_suspend.sh
@@ -13,7 +13,7 @@ test -f /usr/share/acpi-support/key-constants || exit 0
 . /etc/default/acpi-support
 . /usr/share/acpi-support/policy-funcs
 
-if { CheckPolicy || HasLogindAndSystemd1Manager; }; then
+if { CheckPolicy || HasDBusLogin1; }; then
         exit
 fi
 
diff --git a/debian/addons/scripts/sleep_suspendbtn.sh b/debian/addons/scripts/sleep_suspendbtn.sh
index fbd6d6b..11d77d1 100644
--- a/debian/addons/scripts/sleep_suspendbtn.sh
+++ b/debian/addons/scripts/sleep_suspendbtn.sh
@@ -13,7 +13,7 @@ test -f /usr/share/acpi-support/key-constants || exit 0
 
 . /usr/share/acpi-support/policy-funcs
 
-if { CheckPolicy || HasLogindAndSystemd1Manager; }; then
+if { CheckPolicy || HasDBusLogin1; }; then
   # If a power management daemon is running, generate the X "sleep/suspend"
   # key. The daemons will handle that keypress according to their settings.
 



More information about the Pkg-acpi-devel mailing list