1
mirror of https://github.com/qbittorrent/qBittorrent synced 2024-07-26 21:56:20 +02:00

Optional daemon-mode for qbittorrent-nox

This commit is contained in:
Nikolas Garofil 2012-08-18 17:33:51 +02:00
parent 820d94e014
commit 1811ec6cab
2 changed files with 17 additions and 1 deletions

View File

@ -8,7 +8,7 @@ qBittorrent\-nox \- a command line Bittorrent client written in C++ / Qt4
.SH "SYNOPSIS"
\fBqbittorrent\-nox\fR [\-\-webui-port=x] [TORRENT_FILE | URL]...
\fBqbittorrent\-nox\fR [\-\-d|\-\-daemon] [\-\-webui-port=x] [TORRENT_FILE | URL]...
\fBqbittorrent\-nox\fR \-\-help

View File

@ -74,6 +74,8 @@ public:
std::cout << '\t' << prg_name << " --version: " << qPrintable(tr("displays program version")) << std::endl;
#ifndef DISABLE_GUI
std::cout << '\t' << prg_name << " --no-splash: " << qPrintable(tr("disable splash screen")) << std::endl;
#else
std::cout << '\t' << prg_name << " -d | --daemon: " << qPrintable(tr("run in daemon-mode (background)")) << std::endl;
#endif
std::cout << '\t' << prg_name << " --help: " << qPrintable(tr("displays this help message")) << std::endl;
std::cout << '\t' << prg_name << " --webui-port=x: " << qPrintable(tr("changes the webui port (current: %1)").arg(QString::number(Preferences().getWebUiPort()))) << std::endl;
@ -158,6 +160,20 @@ int main(int argc, char *argv[]) {
// Create Application
QString uid = misc::getUserIDString();
#ifdef DISABLE_GUI
bool becomedaemon = false;
for(int i=1; i<argc; i++) {
if(strcmp(argv[i], "-d") == 0 || strcmp(argv[i], "--daemon") == 0) {
becomedaemon = true;
argc--;
for(int j=i; j<argc; j++) {
argv[j] = argv[j+1];
}
}
}
if(becomedaemon && daemon(1, 0) != 0) {
std::cerr << "Something went wrong while transforming into a daemon, exiting...";
return EXIT_FAILURE;
}
QtSingleCoreApplication app("qBittorrent-"+uid, argc, argv);
#else
SessionApplication app("qBittorrent-"+uid, argc, argv);