forked from lubuwest/Friendiqa
Background sync changes
This commit is contained in:
parent
ec102d8d66
commit
b59513ab91
13 changed files with 122 additions and 89 deletions
|
|
@ -52,6 +52,39 @@ void ALARM::setAlarm(int interval)
|
|||
int intDisable = processDisable.execute("systemctl", QStringList() <<"--user"<<"disable"<<"--now"<<"friendiqa-sync.timer");
|
||||
qDebug() << " intEnable "<<intDisable;
|
||||
}else{
|
||||
QString path = QDir::homePath() + "/.config/systemd/user/";
|
||||
QDir dir(path);
|
||||
if(!dir.exists()) {
|
||||
dir.mkpath(path);
|
||||
}
|
||||
|
||||
QString nameService ="friendiqa-sync.service";
|
||||
QFile fileService(path+nameService);
|
||||
fileService.remove();
|
||||
if (fileService.open(QIODevice::ReadWrite)) {
|
||||
QTextStream stream(&fileService);
|
||||
stream << "[Unit]" << Qt::endl;
|
||||
stream << "Description=Run friendiqa background sync" << Qt::endl << Qt::endl;
|
||||
stream << "[Service]" << Qt::endl;
|
||||
stream << "Type=oneshot" << Qt::endl;
|
||||
stream << "ExecStart=/usr/bin/friendiqa -service" << Qt::endl;
|
||||
}
|
||||
|
||||
QString nameTimer ="friendiqa-sync.timer";
|
||||
QFile fileTimer(path+nameTimer);
|
||||
fileTimer.remove();
|
||||
if (fileTimer.open(QIODevice::ReadWrite)) {
|
||||
QTextStream stream(&fileTimer);
|
||||
stream << "[Unit]" << Qt::endl;
|
||||
stream << "Description=Run background sync for Friendiqa periodically" << Qt::endl << Qt::endl;
|
||||
stream << "[Timer]" << Qt::endl;
|
||||
stream << "Unit=friendiqa-sync.service" << Qt::endl;
|
||||
stream << "OnBootSec=10min" << Qt::endl;
|
||||
stream << "OnUnitActiveSec=15min" << Qt::endl << Qt::endl;
|
||||
stream << "[Install]" << Qt::endl;
|
||||
stream << "WantedBy=timers.target" << Qt::endl;
|
||||
}
|
||||
|
||||
QProcess processReload;
|
||||
int intReload = processReload.execute("systemctl", QStringList()<<"--user"<<"daemon-reload");
|
||||
QProcess processEnable;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue