Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frontend: Add --config-dir flag #11838

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions frontend/OBSApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ extern bool opt_disable_updater;
extern bool opt_disable_missing_files_check;
extern string opt_starting_collection;
extern string opt_starting_profile;
extern string opt_config_dir;

extern QPointer<OBSLogViewer> obsLogViewer;

Expand Down Expand Up @@ -1424,6 +1425,14 @@ vector<pair<string, string>> GetLocaleNames()

int GetAppConfigPath(char *path, size_t size, const char *name)
{
if (!opt_config_dir.empty()) {
if (name && *name) {
return snprintf(path, size, "%s/%s", opt_config_dir.c_str(), name);
} else {
return snprintf(path, size, "%s", opt_config_dir.c_str());
}
}

#if ALLOW_PORTABLE_MODE
if (portable_mode) {
if (name && *name) {
Expand All @@ -1441,6 +1450,16 @@ int GetAppConfigPath(char *path, size_t size, const char *name)

char *GetAppConfigPathPtr(const char *name)
{
if (!opt_config_dir.empty()) {
char path[512];

if (snprintf(path, sizeof(path), "%s/%s", opt_config_dir.c_str(), name) > 0) {
return bstrdup(path);
} else {
return NULL;
}
}

#if ALLOW_PORTABLE_MODE
if (portable_mode) {
char path[512];
Expand Down
6 changes: 6 additions & 0 deletions frontend/obs-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ bool opt_disable_missing_files_check = false;
string opt_starting_collection;
string opt_starting_profile;
string opt_starting_scene;
string opt_config_dir;

bool restart = false;
bool restart_safe = false;
Expand Down Expand Up @@ -1033,6 +1034,10 @@ int main(int argc, char *argv[])
} else if (arg_is(argv[i], "--steam", nullptr)) {
steam = true;

} else if (arg_is(argv[i], "--config-dir", nullptr)) {
if (++i < argc)
opt_config_dir = argv[i];

} else if (arg_is(argv[i], "--help", "-h")) {
std::string help =
"--help, -h: Get list of available commands.\n\n"
Expand All @@ -1044,6 +1049,7 @@ int main(int argc, char *argv[])
"\n"
"--profile <string>: Use specific profile.\n"
"--scene <string>: Start with specific scene.\n\n"
"--config-dir <string>: Configuration directory.\n"
"--studio-mode: Enable studio mode.\n"
"--minimize-to-tray: Minimize to system tray.\n"
#if ALLOW_PORTABLE_MODE
Expand Down
Loading