From a0956e95d273da029607f8a6766fc2d8538e11e7 Mon Sep 17 00:00:00 2001 From: hmollercl <30954443+hmollercl@users.noreply.github.com> Date: Mon, 4 Nov 2019 02:55:21 -0300 Subject: [PATCH] allow parameters and pass them directly to redshift, add -v if not already in them, same as rs-gtk (#11) --- main.cpp | 19 ++++++++++++++++++- systemtray.cpp | 4 ++-- systemtray.h | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index 02de5e3..02328fc 100644 --- a/main.cpp +++ b/main.cpp @@ -32,6 +32,23 @@ bool IsInstanceAlreadyRunning(QSharedMemory &memoryLock) { int main(int argc, char *argv[]) { + QStringList argsl = QStringList(); + bool varg = false; + + for (int i = 1; i < argc; ++i){ + if(std::string(argv[i]) == "-h" || std::string(argv[i]) == "--help"){ + qInfo() << "Please run `redshift -h` for help output."; + exit(-1); + } + + if(std::string(argv[i]) == "-v") + varg = true; + + argsl.append(argv[i]); + } + if(!varg) + argsl.append("-v"); + Q_INIT_RESOURCE(resources); QSharedMemory sharedMemoryLock("redshift-qt-lock"); @@ -48,7 +65,7 @@ int main(int argc, char *argv[]) if (!tray.CreateIcon()) return 1; - if (!tray.StartRedshift()) + if (!tray.StartRedshift(argsl)) return 1; globalTray = &tray; diff --git a/systemtray.cpp b/systemtray.cpp index 5ee749b..af74673 100644 --- a/systemtray.cpp +++ b/systemtray.cpp @@ -133,13 +133,13 @@ bool SystemTray::CreateIcon() return true; } -bool SystemTray::StartRedshift() +bool SystemTray::StartRedshift(QStringList argsl) { _redshiftProcess = new QProcess(this); QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); env.insert("LC_ALL", "C"); _redshiftProcess->setProcessEnvironment(env); - _redshiftProcess->start("redshift -v"); + _redshiftProcess->start("redshift", argsl); connect(_redshiftProcess, static_cast(&QProcess::finished), this, &SystemTray::onRedshiftQuit); connect(_redshiftProcess, &QProcess::readyRead, this, &SystemTray::onRedshiftOutput); diff --git a/systemtray.h b/systemtray.h index cf994d8..45ee69b 100644 --- a/systemtray.h +++ b/systemtray.h @@ -15,7 +15,7 @@ class SystemTray SystemTray(); bool CreateIcon(); - bool StartRedshift(); + bool StartRedshift(QStringList); void ToggleRedshift(bool enable = true); void StopRedshift(); void onSuspend();