Bug#1058614: xfce4-power-manager: not suspending when switching to battery if lid is already closed
Package: xfce4-power-manager
Version: 4.18.1-1
Severity: normal
Tags: patch
X-Debbugs-Cc: avforbus@gmail.com
Dear Maintainer,
my settings include:
- lid action on battery: suspend
- lid action on ac: nothing
my scenario is:
- close lid
- disconnect external power supply
expected behavior (this is systemd default behavior with similar conf):
- system should suspend
actual behavior:
- system does nothing
note: when switching the steps in the scenario - first disconnecting and
only then closing the lid - system suspends as expected.
attached a patch that solves the problem, though seems to be a little
bit hackish.
-- System Information:
Debian Release: 12.1
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'proposed-updates'), (500, 'stable'), (100, 'bookworm-fasttrack'), (100, 'bookworm-backports-staging')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 6.1.0-10-amd64 (SMP w/4 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages xfce4-power-manager depends on:
ii libc6 2.36-9+deb12u1
ii libcairo-gobject2 1.16.0-7
ii libcairo2 1.16.0-7
ii libglib2.0-0 2.74.6-2
ii libgtk-3-0 3.24.37-2
ii libnotify4 0.8.1-1
ii libpango-1.0-0 1.50.12+ds-1
ii libpangocairo-1.0-0 1.50.12+ds-1
ii libupower-glib3 0.99.20-2
ii libx11-6 2:1.8.4-2+deb12u1
ii libxext6 2:1.3.4-1+b1
ii libxfce4ui-2-0 4.18.2-2
ii libxfce4util7 4.18.1-2
ii libxfconf-0-3 4.18.0-2
ii libxrandr2 2:1.5.2-2+b1
ii upower 0.99.20-2
ii xfce4-power-manager-data 4.18.1-1
Versions of packages xfce4-power-manager recommends:
ii libpam-systemd [logind] 252.19-1~deb12u1
ii xfce4-power-manager-plugins 4.18.1-1
xfce4-power-manager suggests no packages.
-- no debconf information
Description: handle lid action upon power disconnection when lid is closed
formerly, lid actions were only handled on lid event (close). if lid is already
closed, switching from external power supply to battery didn't trigger the lid
action. now we try to see lid actions as depending on a combination of 2
states: power source and lid state, no matter the order.
.
xfce4-power-manager (4.18.1-1) unstable; urgency=medium
.
* Team upload.
* New upstream version 4.18.1.
Author: Unit 193 <unit193@debian.org>
---
The information above should follow the Patch Tagging Guidelines, please
checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:
Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>)
Bug: <upstream-bugtracker-url>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: (no|not-needed|<patch-forwarded-url>)
Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>)
Reviewed-By: <name and email of someone who approved/reviewed the patch>
Last-Update: 2023-12-13
--- xfce4-power-manager-4.18.1.orig/src/xfpm-power.c
+++ xfce4-power-manager-4.18.1/src/xfpm-power.c
@@ -273,6 +273,7 @@ xfpm_power_check_lid (XfpmPower *power,
{
if (closed != power->priv->lid_is_closed )
{
+ XFPM_DEBUG("closed %d, was %d", closed, power->priv->lid_is_closed);
power->priv->lid_is_closed = closed;
g_signal_emit (G_OBJECT (power), signals [LID_CHANGED], 0, power->priv->lid_is_closed);
}
@@ -329,8 +330,13 @@ xfpm_power_get_properties (XfpmPower *po
"lid-is-closed", &lid_is_closed,
"lid-is-present", &lid_is_present,
NULL);
- xfpm_power_check_lid (power, lid_is_present, lid_is_closed);
+
+ /* in case on battery, use this ugly hack to force rerun of lid handling */
+ if (on_battery && !power->priv->on_battery)
+ power->priv->lid_is_closed = 0;
+
xfpm_power_check_power (power, on_battery);
+ xfpm_power_check_lid (power, lid_is_present, lid_is_closed);
}
static void
Reply to: