[PyKDE] DCOP From Cron
Richard Heck
rgheck at comcast.net
Tue Jun 20 19:28:27 BST 2006
Jim Bublitz wrote:
> On Tuesday 20 June 2006 08:49, Richard Heck wrote:
>
>> İsmail Dönmez wrote:
>>
>>> Salı 20 Haziran 2006 17:19 tarihinde, Richard Heck şunları yazmıştı:
>>>
>>>> I'm writing a simple application to rotate wallpaper every so often, and
>>>> I want to run it as a cron job. The basic structure is pretty simple,
>>>> and it works fine if I run it in a shell under KDE. But when I run it as
>>>> a cron job, it does not connect to the DCOP server. Is there some way to
>>>> tell the script which DCOP server to connect to?
>>>>
>>> Maybe try dcop --user $username .
>>>
>> Sorry, that wasn't clear. The program I'm writing is in Python.
>>
> Yes, but it should be running under cron as the same user you're testing it as
> (the user who owns the display and is running KDE).
>
> Your application should be based on KApplication, and can use
> KApplication.dcopClient() to connect to the DCOP server.
>
Here is the relevant part of the application as it presently exists:
#Create DCOP clients
import kdecore
import dcopext
dcopclient = kdecore.KApplication.dcopClient()
dcopclient.registerAs("changewp")
dcopapp = dcopext.DCOPApp("kdesktop", dcopclient)
and then later we have things like:
dcopapp.KBackgroundIface.setWallpaper(...)
As said, if I run this from a konsole under KDE, it works fine. But if I
CTRL-ALT-F1 and open a terminal outside KDE, then it doesn't work,
despite the fact that I'm running as the same user.
Here's a simple test program:
#/usr/bin/python
#Create DCOP clients
import kdecore
import dcopext
dcopclient = kdecore.KApplication.dcopClient()
dcopclient.registerAs("changewp")
dcopapp = dcopext.DCOPApp("kdesktop", dcopclient)
print dcopapp.KBackgroundIface.currentWallpaper(1)[1]
If I run that from a konsole, I get e.g.
/usr/share/wallpapers/default_gears.jpg. But if I run it from a virtual
terminal, I get: None. And again: I'm the same user both times.
Richard
Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20060620/63848eea/attachment.html
More information about the PyQt
mailing list