From 15ac98299094f5502044fde7820bf4b05a898a83 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Fri, 10 Aug 2012 19:15:18 +0200 Subject: autostart daemon on boot --- sowatchd/main.cpp | 10 +++++----- sowatchd/sowatchd.conf | 13 +++++++++++++ sowatchd/sowatchd.pro | 22 +++++++++++----------- sowatchd/watchhandler.cpp | 2 ++ 4 files changed, 31 insertions(+), 16 deletions(-) create mode 100644 sowatchd/sowatchd.conf (limited to 'sowatchd') diff --git a/sowatchd/main.cpp b/sowatchd/main.cpp index 2816830..7853cde 100644 --- a/sowatchd/main.cpp +++ b/sowatchd/main.cpp @@ -15,14 +15,14 @@ using namespace sowatch; int main(int argc, char *argv[]) { - // Some plugins might require a user interface, so use QApplication instead - // of QCoreApplication - QApplication a(argc, argv); + // Some plugins use QtGui functionality, so QApplication must be used + // instead of QCoreApplication. + QApplication app(argc, argv); QApplication::setOrganizationDomain("com.javispedro.sowatch"); QApplication::setOrganizationName("sowatch"); QApplication::setApplicationName("sowatchd"); - sowatch::daemon = new Daemon(&a); + sowatch::daemon = new Daemon(&app); new DaemonAdaptor(sowatch::daemon); QDBusConnection connection = QDBusConnection::sessionBus(); @@ -33,5 +33,5 @@ int main(int argc, char *argv[]) qCritical("Could not register daemon object"); } - return a.exec(); + return app.exec(); } diff --git a/sowatchd/sowatchd.conf b/sowatchd/sowatchd.conf new file mode 100644 index 0000000..2cebb82 --- /dev/null +++ b/sowatchd/sowatchd.conf @@ -0,0 +1,13 @@ +description "Sowatch daemon" +author "maemo@javispedro.com" + +stop on stopping xsession + +console none + +respawn +respawn limit 3 10 + +nice 2 + +exec /usr/bin/aegis-exec -s -u user -l "exec /opt/sowatch/bin/sowatchd" diff --git a/sowatchd/sowatchd.pro b/sowatchd/sowatchd.pro index 9299f05..f44acdc 100644 --- a/sowatchd/sowatchd.pro +++ b/sowatchd/sowatchd.pro @@ -5,31 +5,31 @@ TEMPLATE = app QT += core gui dbus CONFIG -= app_bundle -SOURCES += main.cpp daemon.cpp daemonadaptor.cpp \ - watchhandler.cpp -HEADERS += global.h daemon.h daemonadaptor.h \ - watchhandler.h +SOURCES += main.cpp daemon.cpp daemonadaptor.cpp watchhandler.cpp +HEADERS += global.h daemon.h daemonadaptor.h watchhandler.h LIBS += -L$$OUT_PWD/../libsowatch/ -lsowatch INCLUDEPATH += $$PWD/../libsowatch DEPENDPATH += $$PWD/../libsowatch -xml.files = service.xml -INSTALLS += xml - +# Library & target paths !isEmpty(MEEGO_VERSION_MAJOR)|maemo5 { QMAKE_RPATHDIR += /opt/sowatch/lib target.path = /opt/sowatch/bin - xml.path = /opt/sowatch/xml } else { target.path = /usr/bin - xml.path = /usr/share/sowatch/xml } INSTALLS += target +# Service files +!isEmpty(MEEGO_VERSION_MAJOR) { + service.files = sowatchd.conf + service.path = /etc/init/apps + INSTALLS += service +} + dbus.path = /usr/share/dbus-1/services dbus.files = com.javispedro.sowatch.service.sowatch-service.service INSTALLS += dbus -OTHER_FILES += scanner.xml \ - daemon.xml +OTHER_FILES += daemon.xml diff --git a/sowatchd/watchhandler.cpp b/sowatchd/watchhandler.cpp index 00d0641..314156a 100644 --- a/sowatchd/watchhandler.cpp +++ b/sowatchd/watchhandler.cpp @@ -65,6 +65,8 @@ void WatchHandler::updateWatchlets() QStringList newWatchlets = _config->value("watchlets").toStringList(); QStringList curWatchlets = _watchlet_order; + if (newWatchlets == curWatchlets) return; // Nothing to do + // TODO: Something better than removing all and readding foreach (const QString& s, curWatchlets) { Watchlet* watchlet = _watchlets[s]; -- cgit v1.2.3