I have set my laptop to suspend after 15 minutes of inactivity, but only on battery. I plugged in my laptop and left it inactive for a long time. When I unplug my laptop, the laptop does not later suspend. My expectation: The laptop should suspend 15 minutes after being unplugged. To test this: 1. Set inactivity timeout to 1 minute to speed up testing. Use this command: xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/inactivity-on-battery -s 1 2. Plug in laptop. 3. Kill existing power manager: killall xfce4-power-manager 4. Run another power manager in debug: xfce4-power-manager --debug --debug --debug --no-daemon 5. Wait 1 minute for the timeout. You'll eventually see this on the screen: TRACE[xfpm-manager.c:493] xfpm_manager_alarm_timeout_cb(): Alarm inactivity timeout id 4 6. Without touching any keys, unplug the power cord. 7. Continue to wait, the laptop will never suspend. The problem is that unplugging or plugging in the laptop doesn't count as activity, so it doesn't reset the timer. The timer already happened so it won't happen again. This will also affect other times, like dimming the screen, etc. One solution is to force timer to reset. There is a dbus command "SimulateUserActivity" that is used in src/xfce-screensaver.c:370 but it didn't work for me because the proxy was false. Also, the heartbeat command doesn't work for me because I don't have xscreensvaer-comand installed. And anyone, that function is not called when the power cable is plugged/unplugged. I suggest that the change of the "on_battery" signal force a reset of all the timers, as if a key were pressed. That could be done in xfpm-manager.c in xfpm_manager_on_battery_changed_cb. Either call the routine in xfce-screensvaer.c (which doesn't work for me as described above) or do something else, like run "xdotool key shift", which simulates pressing the shift key. Maybe it would be best if the on_battery callback called the routine in xfce-screensvaer.c but the HEARTBEAT_COMMAND were customizable for the user, so that I could set it to xdotool. I'm not sure how to do this because I can't understand how to set those properties as a user, if that's even possible.
Okay, I figured it out. I added xfce_reset_screen_svaer to the on_battery_changed callback. Then I set the heartbeat command by typing this: xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/heartbeat-command -n --type string -s "xdotool key shift" I already have xdotool installed. This causes a simulated press of the shift key, which resets the timers. Now the power managements works as I expect. The default is to use dbus SimulateUserActivity, but that didn't work for me and a search on the web shows that it might not be effective anyway: https://bugs.launchpad.net/ubuntu/+source/gnome-screensaver/+bug/1030486 It didn't work for me. Failing that, the default heartbeat-command is "xscreensaver-command -deactivate". I don't have that installed. As I wrote before, even with xcreensaver-command installed, that isn't getting run when the power cord is plugged/unplugged, so the patch is still needed.
Created attachment 8830 Patch to fix bug Tested as described in the bug report.
Any action on this? I have a patch and it's tested and it works. Just 4 lines of code. How do I get this added to the repo?
-- GitLab Migration Automatic Message -- This bug has been migrated to xfce.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.xfce.org/xfce/xfce4-power-manager/-/issues/61. Please create an account or use an existing account on one of our supported OAuth providers. If you want to fork to submit patches and merge requests please continue reading here: https://docs.xfce.org/contribute/dev/git/start#gitlab_forks_and_merge_requests Also feel free to reach out to us on the mailing list https://mail.xfce.org/mailman/listinfo/xfce4-dev