Giter Site home page Giter Site logo

popsulfr / sdh-pausegames Goto Github PK

View Code? Open in Web Editor NEW
78.0 6.0 8.0 2 MB

Decky Loader Plugin for Steam Deck to Pause and Resume games

License: GNU General Public License v3.0

Python 28.80% JavaScript 3.02% TypeScript 68.18%
steam steam-deck decky-loader plugin react signal typescript sigstop game pause

sdh-pausegames's Introduction

Pause Games

A Steam Deck plugin for the Decky Plugin Loader that makes it possible to pause and resume games even for those that don't have an immediate pause option.

Useful for when you wish to temporarily suspend an application in order to redirect the cpu and gpu ressources to another without having to close it.

Since used RAM and VRAM won't be able to be recovered from paused apps you might look into tweaking your swapfile to make things smoother: https://github.com/CryoByte33/steam-deck-utilities

It sends the SIGSTOP signal to all the children of the reaper process to stop the execution and SIGCONT to resume them. (Signal (IPC))

It also allows to pause all games prior to system suspend which seems to fix some issues with crackling audio or freezing emulators.

The Pause on focus loss feature will automatically pause apps that are not in focus when switching between them. A bit like the Xbox quick-suspend/resume feature (without the dump to disk functionality unfortunately). If you manually change the state of an app (pause/resume) in this mode it will be stickied and not change state automatically anymore on focus change (depicted by a blue play/pause icon). To reset the stickied states, disable and re-enable Pause on focus loss.

In addition to Pause on focus loss, Also on overlay will also pause apps when the Steam Overlay is on (by pressing the STEAM button).

Known Issues

  • some games may not like being stopped and resumed too many times over extended periods of play while others work without issues. Make sure to save often if you intend to switch between games with the Pause on focus loss feature enabled.
  • some games may stop responding to input once they are resumed which could be an issue related to the Steam Client getting confused between different control layouts used by the running games. Sometimes force resuming or closing another running game can fix the input issue.

Future ideas

  • options to terminate and force kill more "thoroughly" and immediately a process tree
  • checkpoint/restore support with CRIU to make it possible to dump and restore a game to/from disk (savestates)
    • I already conducted some experiments but the biggest hurdle are the sockets and dri devices which would require many interdependant processes to be checkpointed too
    • A completely isolated process and resource tree seems to be the only viable way currently to get something working (see podman/docker checkpoint/restore) but even then there are host only sockets (pipewire, wayland, xorg) that would need to be taken into account too for games to work

Usage Examples

Tips

  • If you use yuzu (https://yuzu-emu.org/) and want to enable the Pause on focus loss feature, make sure to enable Pause emulation when in background under General Settings in yuzu in order to prevent potentially freezing the emulator completely. You can also Pause/Resume the emulation by binding F4 to a key and press it just before pausing or after resuming the game with the plugin.

sdh-pausegames's People

Contributors

popsulfr avatar therealpaulgg avatar xzzpig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sdh-pausegames's Issues

'Pause before Suspend' useless in some case

I turn on both 'Pause before Suspend' and 'Pause on focus loss'.
When I suspend my steam deck ,It can be noticed that game music pause a little time then continue play, then deck suspend.
When I turn on only 'Pause before Suspend', it seems normal.
I'am using at version 0.4.1,decky version 2.5.4.

Pause on steam overlay functionality

Hi,

I was wondering, as an extension of the 'pause on focus loss', would it be possible to have a feature that when the STEAM button is pressed and the overlay is brought up, the game is suspended? The game would also be paused when browsing the library, or friends tab, etc.

The main idea behind this is there are several games (singleplayer, emulated) that won't automatically pause themselves. It would be desirable to have them auto-pause and unpause when pressing the STEAM button, similar to pressing the Home button on the nintendo switch.

I don't have any experience developing decky plugins but do know JS/TS/react and I'd be happy to contribute to make this happen...was looking here. Specifically the steam overlay is mentioned but I'm unsure if this would even be possible to accomplish or not.

Add blacklist support

Hello!
I personally turn on the Pause on focus loss option by default. But some games/applications are not compatible with it. For example, in some cases, they can not resume without any issue. Would you please add a blacklist to prevent them being paused automatically?
Thank you very much!

Not working in 3.5.19

Not working in steam-os 3.5.19 stable version after i updated steam-os version to the latest

Error message: "Plugin update required to support the new version of the UI."

Opening the settings of any game resumes the last running game with the "Also on overlay"

SteamClient.System.UI.RegisterForFocusChangeEvents() for some reason when opening a popup menu or settings for another game it would callback with an object pertaining to the last running game. So, this leads to the game resuming when navigating menus on any game in case the "Also on overlay" is enabled kinda breaking the point of the feature.

@therealpaulgg If you have a bit of time it would be interesting to have a second perspective/opinion on this (or at least another test that this behaviour is not limited to myself). But don't worry I'll surely figure something out by myself.

So basically when hitting the STEAM button with the "Also on overlay" feature enabled, the game gets paused. Appid is 769, pid is that of the game. Now navigating to another game the appid stays 769 but the pid becomes that of the steamwebhelper. If you click on the cog for a game's properties, the appid stays 769 but for some reason the pid and strExeName become that of the last running game. So the game gets resumed while navigating through the property menus even for other games.

Thinking about the best way to work around this.

It also happens in the Steam Stable Client, weird that I missed that in the rounds of testing.

Manually (un)pausing breaks focus detection

When I (un)pause a game manually, it appears to switch into manual mode and automatic pausing (on unfocus or suspend) does not work anymore.

It would be nice if it could be fixed or if there could be a button to go back to automatic mode ๐Ÿ™‚

Feature Request: Add unpause delay when waking from sleep

I'd like to see a delay added when waking up the deck from sleep, before the game is unpaused when using 'Pause on Sleep' option.

Some games have issues with network disconnects. In particular, I noticed this with Batman: Arkham Asylum. Despite it being a single player game (afaik), it seems to require a network connection. Sometimes when I put it to sleep, it's fine when it wakes. However one time I got a message that the connection to the server was lost, and it kicked me out of the game, losing some progress. Since then I either don't put the deck to sleep while I have it running, or I manually pause it before putting it to sleep.

Ideally, I'd like the plugin to wait until networking is restored before unpausing the game/process (with a possible limit to wake after x seconds even if there's no connection).

Obviously I don't expect this to have any benefit with actual multiplayer games, like MMOs, but games like Arkham Asylum and Borderlands, it would be helpful.

Issue with pausing on focus loss.

Hey y'all,

Lately, I've been experiencing an issue when switching from a non-Steam game like Zelda Windwaker using the Dolphin emulator. Previously, pausing worked fine, but now when I try to switch to other emulated games or PC games, the screen jumps back to the application or game I was switching from. I'm unsure what's causing this behavior.

Additionally, when I get bounced back to the app I was switching from, I've noticed that the game or app I'm switching to is paused. As a result, I have to manually pause the first app and unpause the new one. I hope this description is clear and makes sense. Thanks for your assistance.

Hotkey

Hi! Is it possible to bind a pause to a hotkey combination? I really need this feature because I like to study languages by reading subtitles in video games.

Don't auto pause online games

Currently we can only do auto pause in either all games or no games. I wish online games will not be auto paused since it usually means loss of connection to the server and that's not very far from exiting the game.

As for the way to detect whether a game is an online game, we can probably choose one of the following

  1. Check Steam Store labels, online games will have "Online Co-op" or "Online PvP", the drawback is that the game will not be paused even if it's running in offline mode.
  2. Check if the game's process is listening on any port or something similar, I'm not sure if that could be reliable or not.
  3. Allow users to choose which game to have auto pause, this might be the best solution to have as a third party plugin.

Is it possible to make pause game working with remote play?

This is for Steam Remote Play (LAN streaming). What I want is that when the streaming client switches out of a game (open overlay, go to home screen, etc), the game that is running on the host pauses until the client comes back. It'll be really cool if that would happen. However, I'm not sure if Steam passes any kind of signal when the overlay is opened from the streaming client, thus it may be totally impossible.

Current behavior is that, with Pause Game installed on both host and client, they do nothing. When an overlay is brought up, the music is still playing.

If it's not doable, as an alternative, maybe we can pause the game when the remote play client disconnects, or bring up the overlay when it happens to trigger the pause, so it doesn't immediately restart when the client reconnects?

Focus detection sometimes break

Hello,

I'm using Pause on focus loss and Also on overlay and sometimes the games no longer unpause when going back to them. Manually unpausing them works.

I have not yet find a reliable way to reproduce this but it may be related to going to browsing the library or the Steam store.

Fix time played for paused games

Hey ๐Ÿ‘‹

First off I'd like to say how much I love this plugin! Great work, I use it all the time.

One issue I have noticed is that having games paused in the background appears to increase their "Time played" on Steam. Is there any way to address this?

Thanks

No mouse control

When I have multiple games open at the same time I not longer have mouse control in any of them, whether it's an external mouse of the trackpads set as a mouse

Exiting a game/app/process that is paused will hang until manually un-paused

  • Problem Summary: When attempting to exit a game/app/process that is currently in a paused state, it will hang indefinitely and never fully exit until it is manually un-paused in the decky plugin. This requires manual intervention to un-pause before the exit can be completed successfully.

  • Expected Behavior: Ideally, exiting a paused state should either automatically resume and then close the process, or force close the process to get through the paused state.

  • Steps to Reproduce:

    • Pause the game/app/process.
    • Attempt to exit while in the paused state.
    • Observe that the game hangs and does not exit as expected.
  • Suggested Fix: Implement a check that detects when an exit command is initiated during a paused state and either auto-resumes the process before proceeding with the exit or force close the game.

Suggestion: Quick Resume like Xbox Series

I figured we are already halfway there with SteamOS's sleep/resume function, So I was wondering if it was possible to have a feature akin to the Xbox Series implementation of saving the whole game state into storage and then back in a few seconds.. a literal game changer.

And then I saw this plugin, and then I gasped at the sight of this in your "Future ideas"

checkpoint/restore support with CRIU to make it possible to dump and restore a game to/from disk (savestates

If I understand correctly, a feature similar to Xbox quick resume is what you are trying to achieve with this future idea above right?

I hope it is possible , even if you restrict the dumping from RAM to Storage into just the SSD to maintain fast speeds.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.