Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am building a app with quickly, and I wanted to add a daemon that will run in the background. How do you do this?

share|improve this question
    
You should take a look at D-Bus. –  ADcomp Jul 2 '12 at 21:38
    
Please provide a link to the quickly homepage. With a name like that one cannot google it. –  dotancohen Jul 3 '12 at 10:50
    
What is this deamon supposed to do? Does it need to be public or just for your application? –  Timo Jul 3 '12 at 13:30
    
@dotancohen Done. Although I'd suggest the import bit is that it's in Python. –  8128 Jul 3 '12 at 16:23
    
@Timo I can't speak for Vigesh, but for my bounty I'm looking at something just for my application –  8128 Jul 3 '12 at 16:23

4 Answers 4

As far I know there is nothing specific in quickly to prevent or assist you with running daemons, but there is at least two options I know/guess you can do it with python:

Option #1: Distutils

NOTE: I didn't tried this one yet :)

  1. put your daemon script into the bin directory of your quickly project, e.g.: bin/yourapp-launcher

  2. add the following into the data/yourapp-launcher.desktop file:

    [Desktop Entry]
    Name=Your App
    Exec=/bin/sh -c 'yourapp-launcher'
    Type=Application
    X-GNOME-Autostart-Delay=30
    Icon=yourapp
    Comment=
    NoDisplay=true
    
  3. edit setup.py and specify additional data_files in DistUtilsExtra section, e.g.:

    DistUtilsExtra.auto.setup(
    name='hello-ubuntu',
    version='0.1',
    #license='GPL-3',
    #author='Your Name',
    #author_email='[email protected]',
    #description='UI for managing â¦',
    #long_description='Here a longer description',
    #url='https://launchpad.net/hello-ubuntu',
    cmdclass={'install': InstallAndUpdateDataDirectory},
    data_files=[('/etc/xdg/autostart', ['data/yourapp-launcher.desktop'])]
    )
    

Seems a way to go when daemon must be running for all users, e.g. similar how U1 works.

Option #2: Hardcode

Hardcode everything into your app logic, for example initialize ~/.config/autostart/yurapp-launcher.desktop on the first run, e.g. similar to how GmailNotify App does it.

Unlike GmailNotify App you can relie on the python-xdg library to access freedesktop.org standards:

import xdg
print xdg.BaseDirectory.xdg_config_home

Seems good for user managed daemons.

share|improve this answer

From what I can see there is no template to add a daemon in quickly. However, you can contribute by creating a daemon template. How to create your own template is explained in the answer to this question: How to create a new quickly application template

You could also join the community templates group at Launchpad, to make your template available for others to use.

EDIT: There is also the Unity lens template. It will only work with Ubuntu Unity, so you will be platform dependent (rather significant weakness if you ask me). But it seems to have D-Bus things ready from the start. Kind of like a daemon, but maybe not quite. You could use this as a starting-point to create a platform independent daemon, perhaps...

I don't know any details other than what I can link from others, sorry. Just looking at this myself to find out how to use Qt4 with quickly. EDIT2: Just found that there is a D-Bus component to Qt, which would make your daemon platform independent (working on Windows and Linux etc). This discussion forum (http://www.qtcentre.org/threads/38453-Send-and-receive-a-signal-between-2-Qt-applications) has an example (in C++, but still) of how to use it. Or you can google for QDBusConnection and QDBusMessage.

share|improve this answer

Looking through the Quickly docs, it seems that Quickly does not natively support creating daemons. Therefore I suggest the Python Daemon Library. Also, go over the following Python tutorials that could be interfaced easily from a Quickly application:

Also, this Stack Overflow question addresses Python daemons.

share|improve this answer
    
I have gone through many of the links, but I am looking for a recommended way to connect my quickly GUI app and a daemon that will run in parallel.The daemon has to be packaged with the same app and should be started on boot. –  Vignesh Jul 3 '12 at 18:42
    
Again, Quickly does not support this. You will have to graduate the application from Quickly to 'real' Python. That is why I provided the example links. –  dotancohen Jul 4 '12 at 4:37

Python 3.3 will have a daemon module for the management of daemons.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.