[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyKDE] DCOP From Cron
From: Richard Heck <rgheck () comcast ! net>
Date: 2006-06-20 18:28:27
Message-ID: 44983E4B.9070906 () comcast ! net
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
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
[Attachment #5 (text/html)]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Jim Bublitz wrote:
<blockquote cite="mid200606201014.23450.jbublitz@nwinternet.com"
type="cite">
<pre wrap="">On Tuesday 20 June 2006 08:49, Richard Heck wrote:
</pre>
<blockquote type="cite">
<pre wrap="">İsmail Dönmez wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Salı 20 Haziran 2006 17:19 tarihinde, Richard Heck \
şunları yazmıştı: </pre>
<blockquote type="cite">
<pre wrap="">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?
</pre>
</blockquote>
<pre wrap="">Maybe try dcop --user $username .
</pre>
</blockquote>
<pre wrap="">Sorry, that wasn't clear. The program I'm writing is in \
Python. </pre>
</blockquote>
<pre wrap=""><!---->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.
</pre>
</blockquote>
Here is the relevant part of the application as it presently exists:<br>
<pre>#Create DCOP clients
import kdecore
import dcopext
dcopclient = kdecore.KApplication.dcopClient()
dcopclient.registerAs("changewp")
dcopapp = dcopext.DCOPApp("kdesktop", dcopclient)
</pre>
and then later we have things like:<br>
<pre>dcopapp.KBackgroundIface.setWallpaper(...)
</pre>
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.<br>
<br>
Here's a simple test program:<br>
<pre>#/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]
</pre>
If I run that from a konsole, I get e.g. \
<tt>/usr/share/wallpapers/default_gears.jpg</tt>. But if I run it from a \
virtual terminal, I get: <tt>None</tt>. And
again: I'm the same user both times.<br>
<br>
Richard<br>
<br>
Richard<br>
<br>
</body>
</html>
_______________________________________________
PyKDE mailing list PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic