@ -319,6 +319,9 @@ struct ALIGN_TO_CACHE_LINE StateVars
GameHash running_game_hash = 0 ;
bool running_game_custom_title = false ;
// Prevent screensaver inhibits when running on platforms that don't have it (e.g. gamescope).
bool disable_screensaver_inhibit = false ;
std : : atomic_bool startup_cancelled { false } ;
std : : unique_ptr < INISettingsInterface > game_settings_interface ;
@ -503,11 +506,19 @@ bool System::ProcessStartup(Error* error)
SetRymlCallbacks ( ) ;
# ifdef __linux__
// Running DuckStation out of /usr/lib is not supported and makes no sense.
if ( std : : memcmp ( EmuFolders : : AppRoot . data ( ) ,
" /usr/ "
" lib " ,
8 ) = = 0 )
// Disable screensaver inhibit if running on gamescope.
const char * desktop = std : : getenv ( " XDG_CURRENT_DESKTOP " ) ;
if ( ! desktop )
desktop = std : : getenv ( " XDG_SESSION_DESKTOP " ) ;
if ( ! desktop | | std : : strlen ( desktop ) = = 0 | | std : : strstr ( desktop , " gamescope " ) )
{
INFO_LOG ( " Missing XDG_CURRENT_DESKTOP ({}) or running under gamescope, disabling screensaver inhibit. " ,
desktop ? desktop : " null " ) ;
s_state . disable_screensaver_inhibit = true ;
}
// Running DuckStation out of /usr is not supported and makes no sense.
if ( std : : memcmp ( EmuFolders : : AppRoot . data ( ) , " /usr/ " , 5 ) = = 0 )
return false ;
# endif
@ -3848,6 +3859,9 @@ bool System::ShouldAllowPresentThrottle()
void System : : InhibitScreensaver ( bool inhibit )
{
if ( s_state . disable_screensaver_inhibit )
return ;
Error error ;
if ( ! Host : : SetScreensaverInhibit ( inhibit , & error ) )
{