Bug 328987

Summary: Power saving should not trigger if joystick/controller/gamepad is in use
Product: [Frameworks and Libraries] frameworks-kidletime Reporter: Alvaro Soliverez <asoliverez>
Component: generalAssignee: kdelibs bugs <kdelibs-bugs>
Status: CONFIRMED ---    
Severity: normal CC: afief.h, ahartmetz, andreamilazzo, andrewammerlaan, andysem, angusfk, buzzer.puckers.0n, capone6902, come, comwizz2, darren, david.alejandro.rubio, david.nye, doctorwhoguy, eduardo.cruz, eduardo.ramirez, elvis.angelaccio, fschaupp, gamerminstrel, gamingpondering, ganthore, jackhill3103, jchevarley, jlp, joey.joey586, jordanwood29, joserafaeltic, kde, kde, kdebugs, kdebugs, mahen, makarov.ko.al, mashkal2000, mason2371, mgraesslin, mh, mike, miranda, mosaulp, msdobrescu, nate, oguilherme, postix, rafael.linux.user, rando7, reddit.pettiness697, salvatore, sobolevsam, spamless.9v5xj, synthaxx, timofeevsv1989, timonoj, tinozzo123, tomenglund26, unblended_icing552
Priority: VHI    
Version: 6.0.0   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:

Description Alvaro Soliverez 2013-12-19 01:04:46 UTC
I play games using a joystick. After 10 min, the monitor turns off until I hit a key or move the mouse.

It is not detecting that there is input activity, but in the joystick, not via mouse or keyboard.

Adding back the option to turn off power saving when fullscreen is another possibility.


Reproducible: Always
Comment 1 Mancausoft 2014-03-07 11:22:42 UTC
I have the same problem in kde from debian testing.
When I play games using a joystick, the monitor decrease luminosity. 

Reproducible: Always
Comment 2 Kai Uwe Broulik 2015-01-26 20:58:56 UTC
PowerDevil uses KIdleTime to track an idle session, re-assigning.
Comment 3 Côme Chilliet 2015-10-07 15:40:11 UTC
This is a big problem!
It basically means I can’t play videogames without having to disable screensaver first…

Is this a complicated thing to fix?
Comment 4 Kai Uwe Broulik 2015-12-13 23:31:00 UTC
*** Bug 356636 has been marked as a duplicate of this bug. ***
Comment 5 Martin Flöser 2015-12-14 07:06:04 UTC
As I don't have a joystick: could someone please run the tool "xev" and see whether there are input events shown when using the joystick and if what kind of events are reported?
Comment 6 Côme Chilliet 2015-12-15 07:28:44 UTC
(In reply to Martin Gräßlin from comment #5)
> As I don't have a joystick: could someone please run the tool "xev" and see
> whether there are input events shown when using the joystick and if what
> kind of events are reported?

No, nothing shows up in xev when I press buttons on my gamepad.
Comment 7 Afief Halumi 2015-12-15 19:23:29 UTC
Tried this in both Kubuntu 15.10 and Ubuntu 15.10, xev doesn't show any notifications from the gamepad. Don't mind testing it on other systems as well if you think this helps.
Comment 8 Martin Flöser 2015-12-16 07:12:59 UTC
Thanks a lot for the testing! It's unfortunately what I expected, the gamepad bypasses the X-Server which means our normal interaction in KIdleTime just doesn't/cannot work :-(
Comment 9 Afief Halumi 2015-12-17 08:41:37 UTC
Would donating a gamepad to a developer help or is this issue too far out of scope for KIdleTime? The input-devices in systemsettings seems to be aware of of the joysticks and be able to get their events, so perhaps it is dealt with in another part of KDE already.

Out of curiosity, is this X specific or will this affect Wayland as well? (i.e. will this bug solve itself as soon as the Wayland transition is complete?)
Comment 10 Martin Flöser 2015-12-17 09:19:53 UTC
> Would donating a gamepad to a developer help or is this issue too far out of scope for KIdleTime?

I have a gamepad for my playstation. Need to try whether it works at all on linux.

> Out of curiosity, is this X specific or will this affect Wayland as well?

I don't know yet. But actually that's the part I want to test with the gamepad. If it's fixed on Wayland it's unlikely that we will get support for it in KIdleTime on X11. If it works in neither, I will look into what could be a solution for KIdleTime. It might mess with the functionality a lot, so no promise that it can be fixed.
Comment 11 Martin Flöser 2015-12-17 12:17:26 UTC
gamepad works, I see the events in the joystick kcm. Now the bad news: libinput doesn't provide support for it, see [1]. Which means also on Wayland we don't get the events into KIdleTime.

Now getting this into KIdleTime is tricky. We would need to add a second source for checking idle and only consider the session as idle if both sources are idle. Not an easy change. Even more we would need to move the monitoring of joysticks into the applications, while monitoring of pointer/keyboard/touch is inside the display server. All applications using KIdleTime would then get woken up on each event. Not good. This needs serious thinking on how to integrate it and will take time.

[1] http://lists.freedesktop.org/archives/wayland-devel/2015-January/019462.html
Comment 12 Martin Flöser 2016-06-21 15:40:15 UTC
*** Bug 364592 has been marked as a duplicate of this bug. ***
Comment 13 Martin Flöser 2016-08-09 05:34:01 UTC
*** Bug 366529 has been marked as a duplicate of this bug. ***
Comment 14 Elvis Angelaccio 2017-06-28 20:38:47 UTC
What if we had instead a standard way for applications to say "hey, I'm using the joystick, please don't lock the screen" ? Would it be possible from a technical point of view?
Comment 15 Elvis Angelaccio 2017-06-28 20:58:09 UTC
On the other hand, from the Martin's link above the reason why X11 and libinput ignore joysticks seems to be "too much joysticks; no real use case".

But I think that idle detection is a valid use case, not every game out there uses modern libraries like SDL. And to have working idle detection we would need a very simple information from xcb/libinput: "joystick unused" vs "something pressed on the joystick".
Comment 16 Lastique 2017-06-28 21:25:30 UTC
(In reply to Elvis Angelaccio from comment #14)
> What if we had instead a standard way for applications to say "hey, I'm
> using the joystick, please don't lock the screen" ? Would it be possible
> from a technical point of view?

The API to disable power saving/screen locking must already exist - most video players use it. The problem is that the API must be used by the application, and you can't expect every game disable power saving. Also, in case if the application crashes, chances are high that the power saving remains disabled.

I wonder if KIdleTime could instead listen for /dev/input/js* and /dev/input/event* events as an indication of user input.
Comment 17 Elvis Angelaccio 2017-06-28 22:03:48 UTC
Right, I didn't think about video players. It seems we already have a standard dbus api for this. We surely can't expect every game to use it, but at least "hubs" like steam and dolphin-emu could, imho.
Comment 18 Andreas Hartmetz 2017-07-07 00:53:10 UTC
Most games do, in fact, inhibit power saving. If you have a game running and open the energy management tray thingie, it will even tell you the name of the game blocking power saving (unfortunately, most don't bother changing the default so they are called something like "an SDL application").
AFAIK the power management inhibition is tied to the DBus name of the application. If the application dies, its DBus name vanishes, and the inhibition is removed as well.
All these are not reasons against a workaround for sloppily programmed games, I am just saying that the power management inhibition system works very well when it is used.
Comment 19 Lastique 2017-07-07 07:49:28 UTC
(In reply to Andreas Hartmetz from comment #18)
> If the application dies, its DBus name vanishes, and the
> inhibition is removed as well.

[offtopic]
In the past, I had multiple cases when a video player died and power saving was not restored. Granted, I am not familiar with technical details and have no idea what could have caused this or if this was fixed somewhere (I didn't have player crashes for a long time). It's just apparently there might be a case where power saving remains disabled.
[/offtopic]

> All these are not reasons against a workaround for sloppily programmed games

Absolutely.
Comment 20 Mahendra Tallur 2018-10-18 09:38:20 UTC
Hi ! Would it be possible to add an option in the "KWin Rules" utility to bypass the screen blanking ? 

I noticed this problem occurs when playing Wine games (i.e. through Steam Play). My monitor is put to sleep after 10 mins when playing with a gamepad/joystick controller.

I did add a kwin rule to disable compositing for wine but it seems there no option related to the energy settings.

Of course, the other way would be to make wine / steam play disable the screensaver.
Comment 21 Martin Flöser 2018-10-18 16:52:57 UTC
(In reply to Mahendra Tallur from comment #20)
> Hi ! Would it be possible to add an option in the "KWin Rules" utility to
> bypass the screen blanking ? 
> 
No, KWin is not involved in dpms.
Comment 22 Kai Uwe Broulik 2019-04-25 07:31:14 UTC
*** Bug 406853 has been marked as a duplicate of this bug. ***
Comment 23 Kai Uwe Broulik 2020-04-01 06:54:02 UTC
*** Bug 419460 has been marked as a duplicate of this bug. ***
Comment 24 Patrick McMunn 2020-04-01 12:53:05 UTC
Since this is such a longstanding bug with apparently no easy solution, maybe a possible workaround or alternative way of dealing with it could be adding a sort of "Gsme Mode" to KDE. It could simply be a quick-access widget of some kind that's configurable to do things like disable the screensaver, power management and compositing. Maybe it would even be possible to add a list of applications to it do that, whever an application on the list is launched, game mode automatically activates. The widget could monitor whether the specified applications are running, and then deactivate game mode automatically when the application is either exited normally or crashes. Would something like that be possible?
Comment 25 Kai Uwe Broulik 2020-04-01 13:15:39 UTC
Battery Monitor → Uncheck "Enable power management".

Most modern games actually do.
Comment 26 Lastique 2020-04-01 14:33:01 UTC
(In reply to Kai Uwe Broulik from comment #25)
> Most modern games actually do.

No, I wouldn't say so. You can see it happen even on Windows if you leave a game running with no user input - the display turns off after a while. But on Windows games don't have to do anything about it as gamepad input cancels powersaving on that OS.
Comment 27 Lastique 2020-04-01 14:46:18 UTC
As a personal workaround I'm using the lightsOn.sh script written by someone. Here is my fork with some improvements:

https://github.com/lastique/lightson

It works on X11 system and blocks powersaving if there are any fullscreen windows. It works for fullscreen video players in browsers and games.

I know that KWin is not involved in DPMS, but I wonder if it would be possible to implement that kind of rule in it. Or more generally - block DPMS if there is a window matching some criteria set by user, with "fullscreen" being one example. As a bonus, it could work in Wayland as well (I'm not sure if lightsOn.sh is even possible to implement on Wayland).
Comment 28 Nate Graham 2020-04-21 17:16:17 UTC
*** Bug 420359 has been marked as a duplicate of this bug. ***
Comment 29 soredake 2020-07-11 12:06:46 UTC
Any progress on this?
Comment 30 soredake 2021-01-06 08:30:18 UTC
Right now as workaround i use https://github.com/FeralInteractive/gamemode
Comment 31 Andrew Nowa Ammerlaan 2022-09-22 16:42:28 UTC
What is interesting to me is that when only using a controller, the screen eventually turns off but it does not lock. I.e. controller input seems to prevent the "Lock screen automatically --> After X" setting from triggering but not the "Screen Energy Saving" setting. Do these two settings use different methods for checking input activity?

Plasma 5.25.5 (wayland), frameworks 5.98.0, Qt 5.15.5
Comment 32 Nate Graham 2023-02-13 01:50:49 UTC
*** Bug 465541 has been marked as a duplicate of this bug. ***
Comment 33 ariasuni 2023-03-14 03:41:51 UTC
I noticed this problematic behavior with a Switch Pro Controller, wired or in Bluetooth, Wayland or X11.
Comment 34 Mihai Sorin Dobrescu 2023-06-14 11:33:18 UTC
I have the issue on two systems:

Operating System: MocaccinoOS (Gentoo based)
KDE Plasma Version: 5.27.5
KDE Frameworks Version: 5.106.0
Qt Version: 5.15.9
Kernel Version: 6.1.32-mocaccino (64-bit)
Graphics Platform: X11
Processors: 16 × 11th Gen Intel® Core™ i7-11700K @ 3.60GHz
Memory: 61.6 GiB of RAM
Graphics Processor: NVIDIA GeForce GTX 1060 6GB/PCIe/SSE2
Manufacturer: ASUS
Comment 35 Nicolas Fella 2023-06-21 18:01:39 UTC
*** Bug 471047 has been marked as a duplicate of this bug. ***
Comment 36 Nate Graham 2023-08-04 19:39:58 UTC
*** Bug 472465 has been marked as a duplicate of this bug. ***
Comment 37 Rafael Linux User 2023-12-09 00:56:21 UTC
Same here using Wayland. Wired MS XBOX 360 Pad / Switch Pro Controller.

Operating System: openSUSE Tumbleweed 20231206
KDE Plasma Version: 5.27.9
KDE Frameworks Version: 5.112.0
Qt Version: 5.15.11
Kernel Version: 6.6.3-1-default (64-bit)
Graphics Platform: Wayland
Processors: 24 × AMD Ryzen 9 3900X 12-Core Processor
Graphics Processor: AMD Radeon RX 7600
Product Name: B550M Phantom Gaming 4
Comment 38 david.nye 2024-01-13 07:26:50 UTC
Also experiencing this bug. It is a problem when using Steam.

System details:

Operating System: Gentoo Linux 2.14
KDE Plasma Version: 5.27.10
KDE Frameworks Version: 5.113.0
Qt Version: 5.15.11
Kernel Version: 6.1.67-gentoo-x86_64 (64-bit)
Graphics Platform: Wayland
Comment 39 timonoj 2024-01-17 08:03:54 UTC
Wow this is an ELEVEN (!) year old bug. Same issue here. Dual Shock 4 controller connected via bluetooth, playing on Steam.
Comment 40 Rafael Linux User 2024-01-17 09:15:14 UTC
(In reply to timonoj from comment #39)
> Wow this is an ELEVEN (!) year old bug. Same issue here. Dual Shock 4
> controller connected via bluetooth, playing on Steam.

XD LOL ... I guess this is your first bug confirmation/report... I have reported errors the same and even more years ago than this one. But the priorities or importance (in this case "HI normal") we (users) give to it is relative - that's what I've been told when I've asked about it - so, this may be here until Windows creates a desktop for Linux ....
Comment 41 PocketSam 2024-01-19 12:48:46 UTC
Fedora 39, Wayland, KDE, Steam installed via Flatpak, using not joystick but gamepad (Vader 2) and my Monitor switches off according to power settings.
Comment 42 Michael Rogers 2024-01-24 02:52:33 UTC
Just a note to help those effected, launching the game through "gamemoderun" wrapper (Or adding it to the steam launch commands [gamemoderun %command%]) Will keep the screen awake while playing, and can have some other benefits to system tweaking if desired, there is also an applet in kde that allows you to temporarily disable screen timeout
Comment 43 Rafael Linux User 2024-01-24 08:34:33 UTC
(In reply to Michael Rogers from comment #42)
> Just a note to help those effected, launching the game through "gamemoderun"
> wrapper (Or adding it to the steam launch commands [gamemoderun %command%])
> Will keep the screen awake while playing, and can have some other benefits
> to system tweaking if desired, there is also an applet in kde that allows
> you to temporarily disable screen timeout

Thank you for sharing. I didn't know that feature of "gamemoderun". It's a interesting workaround if only using one games launcher. In my case, I use more tha four (Heroic, Yuzu, PPSP, Lutris) so in my case, I prefer to wait for a fix for this.
Comment 44 Xoloitzcuintli 2024-02-13 18:34:04 UTC
I'm experiencing this bug as well.

Operating System: Void Linux
KDE Plasma Version: 5.27.10
KDE Frameworks Version: 5.115.0
Qt Version: 5.15.11
Kernel Version: 6.6.16_1 (64-bit)
Graphics Platform: Wayland
Comment 45 Holmes 2024-02-21 23:58:18 UTC
Is there any hope that this bug will be fixed before the heat death of the universe?
Comment 46 Darren Anderson 2024-03-07 07:15:02 UTC
Same issue here - using xone with the Xbox wireless dongle.

Distro: Arch
Kernel: 6.7.8-arch1-1
KDE Plasma Version: 6.0.1
KDE Frameworks Version: 5.155.0
Display Server: Wayland

Looks like this might actually be an issue with KWin though as opposed to kidletime. Ultimately, the idle detector here drives the behaviour in kidletime, and by extension kscreenlocker. Currently this is only listening for key, pointer, touch, gesture and tablet events as a trigger for inhibiting the idle detector. Presumably the fix for this would be to also include gamepad events here too.
Comment 47 Darren Anderson 2024-03-07 08:17:05 UTC
Did a bit more digging into this, and it seems non-trivial. As of now, KWin receives input from "backends", of which there are several (Wayland, X11, libinput etc).

It seems like gamepads exist outside of this usual architecture, as the input would come from the gamepad device itself, rather than via X11, Wayland, libinput etc.

Not the nicest solution ever, but I wonder if we might get around this by adding the gamepad read functionality to the base `InputDevice` class? That way it would work across multiple backends, even if it is a bit of a deviation from the current design.
Comment 48 Joe 2024-03-14 02:09:16 UTC
I also just experienced this using a Steam Controller on the latest Plasma 6.0.1 release when trying out the FF7 remake. Screen goes to sleep even with controller input - work around right now is just manually inhibiting sleep/suspend and re-enabling.
Comment 49 Waifu4Life 2024-03-16 16:30:27 UTC Comment hidden (spam)
Comment 50 fschaupp 2024-05-25 17:44:14 UTC
(In reply to Joe from comment #48)
> I also just experienced this using a Steam Controller on the latest Plasma
> 6.0.1 release when trying out the FF7 remake. Screen goes to sleep even with
> controller input - work around right now is just manually inhibiting
> sleep/suspend and re-enabling.

I have the same issue.
Comment 51 ALP 2024-05-28 15:32:19 UTC
I have the same problem with Logitech G29 gaming racing wheel. The screen locks after a few minutes of playing. This was on Fedora 39 KDE Plasma 5.27 too.

Operating System: Fedora Linux 40
KDE Plasma Version: 6.0.5
KDE Frameworks Version: 6.2.0
Qt Version: 6.7.0
Kernel Version: 6.8.10-300.fc40.x86_64 (64-bit)
Graphics Platform: Wayland
Comment 52 Jakob Petsovits 2024-06-03 02:41:16 UTC
*** Bug 486292 has been marked as a duplicate of this bug. ***
Comment 53 Mike Lothian 2024-06-03 18:29:07 UTC
Is it worth raising a bug with libinput
Comment 54 Zamundaaa 2024-06-06 17:02:58 UTC
*** Bug 447099 has been marked as a duplicate of this bug. ***
Comment 55 Nate Graham 2024-06-25 14:04:39 UTC
*** Bug 489177 has been marked as a duplicate of this bug. ***
Comment 56 José Rafael 2024-06-30 22:30:23 UTC
Regardless of whether you have control or not, this bug of turning off, blocking the screen happens when you watch videos on firefox or telegram for example, Plasma is not respecting the rule that shows on the power plasmoid that the application is preventing from turning off the screen!
It also happens if the game is paused without using the mouse, the monitor turns off and locks!

Arch Linux
Plasma 6.1.1
KDE Frameworks: 6.3.0
Qt: 6.7.2
Kernel 6.9.7-arch1-1
Wayland

Fedora Atomic Kinoite 40
Plasma 6.1.1
KDE Frameworks: 6.3.0
Qt: 6.7.1
Kernel: 6.9.6-200.fc40.x86_64
Wayland
Comment 57 spamless.9v5xj 2024-07-13 16:32:15 UTC
I'm actually a little confused - shouldn't "block sleep and screen locking" just block it period, regardless of whether there is user input or not?

Also FWIW I can't recall encountering this bug when using my Xbox 360 wired controller, only when using my G923.