[Pkg-xfce-devel] xfce4-power-manager BUG + possible FIX
first time I try to give some feedback, so please don't feel offended, or even beat me, if this is not the right place to report.
Running xfce4-power-manager on a lubuntu 16.04 system using a laptop running on battery I kept receiving the following notification 'GDBus.Error:org.freedesktop.DBus.Error.AccessDenied:Permission denied'
Investigating further it turned out, there was a discrepancy between 'xfce4-power-manger-settings' GUI reporting the sleep mode on battery to be "Suspend" and 'dbus-monitor --system' reporting the real action taking place to be an attempt to go into "Hibernate" mode (relevant part cited below), which in turn is disabled via polkit-1 on my system.
method call time=1469228622.268937 sender=:1.62 -> destination=org.freedesktop.login1 serial=25 path=/org/freedesktop/login1; interface=org.freedesktop.login1.Manager; member=Hibernate
STEPS TO REPRODUCE
1. reset/remove xfce-power-manager.xml configuration
2. disable action "org.freedesktop.login1.hibernate" via polkit-1
3. unplug laptop from power source
4. keep doing nothing for 15 minutes
Digging the sources I found the problem to be split between src/xfpm-xfconf.c:489 setting the default value of the property "inactivity-sleep-mode-on-battery" to XFP_DO_HIBERNATE and 'xfpm_settings_on_battery()' in settings/xfpm-settings.c:863 narrowing down possible ComboBox options down to those actually supported by system policy.
Given an empty/default xfce4-power-manager.xml configuration and via system policy disabled hibernate this leads to the funny fact that 'xfce4-power-manager-settings' GUI will not only wrongly "report" the selected sleep mode to be "Suspend".
But even worse never never never ever allow the user to really switch sleep mode on battery to "Suspend", as to fire the necessary callback it would be necessary to actually change the ComboBox selection, which given a single choice is impossible.
I managed to circumvent the problem manually adding: <property name="inactivity-sleep-mode-on-battery" type="uint" value="1"/> to the configuration file, but probably this might not be the most obvious i.e. user friendly way to handle such situations.
To handle scenarios like the one described with either "Suspend", "Hibernate", or even both unavailable imho it wouldn't be too painful to allow XFPM_DO_NOTHING as another option for both properties "inactivity-sleep-mode-on-battery" and "inactivity-sleep-mode-on-ac".
This would not only allow to select either "Suspend" or "Hibernate" even if the other one isn't available still firing the necessary callback in 'xfce4-power-manager-settings', but also allow to still show a meaningful value in the GUI in case both of them are unavailable.
I put a patch just doing this in the attachment.
imho lowering the "magic" never timeout value from 14 to 0 and allowing a range starting from 0 wouldn't be to painful, especially for testing purposes. :) I know it is already possible to use lower values manually hacking the config file, but again probably this is not the most obvious and user-friendly way.
Bernd <s1237382 at gmail.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2881 bytes
Desc: not available