ares-emulator / ares

ares is a cross-platform, open source, multi-system emulator, focusing on accuracy and preservation.
https://ares-emu.net
Other
989 stars 121 forks source link

Computer goes to sleep while playing game #1577

Open jure965 opened 3 months ago

jure965 commented 3 months ago

Describe the bug Computer goes to sleep while playing game using controller.

To Reproduce Steps to reproduce the behavior:

  1. Start Ares
  2. Load and play game using controller
  3. After a while computer goes into sleep mode

Expected behavior Computer may not go into sleep mode during a gaming session.

Screenshots Power management settings: Screenshot_20240725_222752

Additional context OS/Distribution: Arch Linux Window manager: KWin/Wayland Desktop environment: KDE Plasma 6 Input controller: 8BitDo SN30 Pro USB gamepad, presents itself as a USB device ID 045e:028e Microsoft Corp. Xbox360 Controller Game/Emulator: Chrono Trigger, Nintendo Super Famicom

For now, I periodically wiggle mouse or disable sleep altogether to prevent computer from going to sleep while playing games on ares.

Video player VLC for example keeps computer awake while playing video without user input.

Let me know if additional information is needed.

Screwtapello commented 3 months ago

For whatever reason, screensavers on Linux do not regard gamepad input as "input", so they don't prevent the screensaver from activating.

Unfortunately, there's no standard way to inhibit the screensaver that works on all Linux systems. There's a method for the built-in X11 "blank screen" screensaver, a method for GNOME, a method for the XScreensaver app, and so forth. ares uses the xdg-screensaver command-line tool which is supposed to handle all these variants, but I don't know how universally that tool is available, and I don't know if it supports whatever method KDE uses to inhibit the screensaver.

https://github.com/ares-emulator/ares/blob/723d8a8cd4a7d272331230fddfea37cf5ab6dfae/hiro/gtk/application.cpp#L70-L89

sp1187 commented 3 months ago

I think the recommended way of inhibiting the screensaver on modern Linux systems is to use the org.freedesktop.ScreenSaver.Inhibit and org.freedesktop.PowerManagement.Inhibit (or possibly the newer org.freedesktop.login1.Inhibit) DBus APIs. I assume the ares implementation could be changed to use those where available.

jvengustnchain commented 3 months ago

I do have xdg-utils installed and xdg-screensaver command is available. May I get an example way to test if it works on my system? I will report a bug upstream to xdg-utils if it doesn't work.