From 0c6dc194febe16161ca8d0b44b7a8aeb5b135d09 Mon Sep 17 00:00:00 2001 From: Martin Gawlita Date: Fri, 11 Sep 2026 15:45:34 +0200 Subject: [PATCH] Add command-line option to start the Remote API server --- README.md | 26 ++++++++++++++++++++++++++ src/main.cpp | 13 +++++++++++++ 2 files changed, 39 insertions(+) diff --git a/README.md b/README.md index 396eaa3..31ca818 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,32 @@ Current version: v1.4.1 Qt5.15 C++17 +## Command-line options + +Pass `--server` to enable the Remote API server automatically when Open Sound Meter +starts. This is equivalent to turning on **Server** in the Remote API panel and is +useful for login/startup shortcuts: + +```powershell +# Windows (from the installation directory) +.\OpenSoundMeter.exe --server +``` + +```sh +# macOS +open -a OpenSoundMeter --args --server + +# Linux +./OpenSoundMeter --server +``` + +The application still opens its normal graphical interface and requires a desktop +session. The option applies only to this launch; without it, the server remains +off at startup. The Server switch can still be used to stop and restart it. +Remote generator control remains a separate option in the Remote API panel. + +Use `--help` to list options or `--version` to print the application version. + ## SAST Tools diff --git a/src/main.cpp b/src/main.cpp index 304afbe..8bb3a8c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,6 +16,7 @@ * along with this program. If not, see . */ #include +#include #include #include #include @@ -84,6 +85,14 @@ int main(int argc, char *argv[]) QCoreApplication::setOrganizationName("opensoundmeter"); QCoreApplication::setOrganizationDomain("opensoundmeter.com"); + QCommandLineParser parser; + parser.setApplicationDescription("Sound measurement software for tuning sound systems."); + parser.addHelpOption(); + parser.addVersionOption(); + const QCommandLineOption serverOption("server", "Start the Remote API server with the application."); + parser.addOption(serverOption); + parser.process(app); + Settings settings; Appearance appearence(&settings); audio::Client::getInstance(); @@ -141,5 +150,9 @@ int main(int argc, char *argv[]) if (engine.rootObjects().isEmpty()) return -1; + if (parser.isSet(serverOption)) { + server.setActive(true); + } + return QApplication::exec(); }