Skip to content

Commit 9f6f1db

Browse files
committed
main: allow overriding the backend with the value of a ConVar
1 parent 02f91de commit 9f6f1db

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/backend.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ extern bool g_bAllowDeferredBackend;
1515

1616
namespace gamescope
1717
{
18+
ConVar<std::string> cv_backend( "backend", "auto", "Override the backend selection (auto-detected or specified on the command line)." );
19+
1820
ConVar<VirtualConnectorStrategy> cv_backend_virtual_connector_strategy( "backend_virtual_connector_strategy", VirtualConnectorStrategies::SingleApplication );
1921

2022
/////////////

src/backend.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ namespace gamescope
3131
class BackendBlob;
3232
class INestedHints;
3333

34+
extern ConVar<std::string> cv_backend;
35+
3436
namespace VirtualConnectorStrategies
3537
{
3638
enum VirtualConnectorStrategy : uint32_t
@@ -504,4 +506,3 @@ inline gamescope::IBackend *GetBackend()
504506
{
505507
return gamescope::IBackend::Get();
506508
}
507-

src/main.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,14 @@ int main(int argc, char **argv)
880880
g_pOriginalDisplay = getenv("DISPLAY");
881881
g_pOriginalWaylandDisplay = getenv("WAYLAND_DISPLAY");
882882

883+
// Allow overriding the selected backend (even the backend
884+
// requested on the command line) in a startup script.
885+
auto backendOverride = parse_backend_name( gamescope::cv_backend.Get().c_str() );
886+
if ( backendOverride != gamescope::GamescopeBackend::Auto )
887+
{
888+
eCurrentBackend = backendOverride;
889+
}
890+
883891
if ( eCurrentBackend == gamescope::GamescopeBackend::Auto )
884892
{
885893
if ( g_pOriginalWaylandDisplay != NULL )

0 commit comments

Comments
 (0)