Skip to content

Commit

Permalink
allow parameters and pass them directly to redshift, add -v if not al…
Browse files Browse the repository at this point in the history
…ready in them, same as rs-gtk (#11)
  • Loading branch information
hmollercl authored and Chemrat committed Nov 4, 2019
1 parent d410d38 commit a0956e9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
19 changes: 18 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions systemtray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<void (QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, &SystemTray::onRedshiftQuit);
connect(_redshiftProcess, &QProcess::readyRead, this, &SystemTray::onRedshiftOutput);
Expand Down
2 changes: 1 addition & 1 deletion systemtray.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SystemTray
SystemTray();

bool CreateIcon();
bool StartRedshift();
bool StartRedshift(QStringList);
void ToggleRedshift(bool enable = true);
void StopRedshift();
void onSuspend();
Expand Down

0 comments on commit a0956e9

Please sign in to comment.