LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (http://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Desktop Wallpaper program (http://www.linuxquestions.org/questions/linux-desktop-74/desktop-wallpaper-program-516510/)

sadarax 01-05-2007 04:11 AM

Desktop Wallpaper program
 
I am thinking of trying to write my own Desktop Wallpaper program. How is the desktop wallpaper controlled within KDE? Is there an API for setting the wallpaper on the desktop(s)? Also, is there a more general method for setting the background, something that is control my the X-Session (I am using Xorg)?

I am thinking of trying to write my own Desktop Wallpaper program. I have several features in mind for it. Currently I have not found a good wallpaper program that does most of them. I hope this is the right forum.

One other thing, is there a way to know when a screen saver is active on a desktop? I am sure I could perform some hack using the 'ps' command and grepping the output, but I am looking for a better solution. Thanks in advance.

FnordPerfect 01-05-2007 04:56 AM

What you see in the background behind all application windows is called the 'root window' in X11 terminology.

Without KDE (or similar), any program could draw on that "window". Before I switched to KDE, I used the 'xv' image viewer to set an image in the root window, but there are countless alternatives.
Even screensavers or video players could run within the root window, behind your applications! I was pretty impressed by that when I made my first steps with Linux.

However, with KDE running, KDE's kdesktop component "overpaints" this area.

Have a look at KDE's DCOP (Desktop COmmunication Protocol). This is KDE's powerful and easy-to-use Inter-Process-Communication subsystem.
Most KDE applications expose parts of their functionality through this interface.
I am not a programmer at all, but with this, even I can hack together some very nifty things to make KDE do what I want.

I don't know which language you want to implement your program, but there are DCOP-hooks available for pretty much all languages...

If you want to put together a simple shell script, there is a command line utility named 'dcop'.
Without arguments, it shows all registered DCOP services. Use that or use kdcop to browse them graphically, and play around with it. It is pretty self-explanatory.

Type
Code:

dcop kdesktop KBackgroundIface
at a terminal to see all functions that control background drawing.
I guess, setWallpaper is the function you are looking for.

Alas, I cannot help you with your second question...

cheers

javaunixsolaris 05-30-2007 12:35 PM

how to change KDE desktop wallpaper from cmd line
 
FnordPerfect, you rock! I can't find the dcop API and there's no man page! but guessing based off of the method names is probably good enough. Here's how to change your wallpaper from the command line:D:

Code:

dcop kdesktop KBackgroundIface setWallpaper /tmp/whateverpicyouwant.jpg 5
The code tag above looked like sh*t in my firefox so here it is unadulterated:dcop kdesktop KBackgroundIface setWallpaper /tmp/whateverpicyouwant.jpg 5
mode 5? who knows no API, it looks best I'm guessing "tiled not scaled".

I'm planning on writing a script to download a new pic and change my background everyday, I'll keep you guys posted.

javaunixsolaris 09-25-2007 06:28 PM

I know it's been ages but I got back to this program, running the dcop command from a cron will give you "ERROR: Couldn't attach to DCOP server!" I checked whoami and it is me and I can run the command just fine.

sadarax 09-25-2007 06:35 PM

I wish I could help you, but I'm not sure about the problem. Is KDE/KDM running? Are you running the command from a shell window?

javaunixsolaris 09-26-2007 10:22 AM

Here's everything:

Code:

$ dcop kdesktop KBackgroundIface setWallpaper /tmp/astronomyPicOfDay/070925/zodiacal_beletsky.jpg 5
Works great from the command line (make sure to use a full path of a real picture) now make a JOB file (a.job):
Code:

#This is a crontab file to download astronomy pic of the day everynight.
#CRON: minute hour day_of_month month day_of_week COMMAND

#The cron output itself
MAILTO=USE_YOUR_EMAIL_TO_SEE_OUTPUT@email.com
SHELL=/bin/bash

#Get astronomy pic of the day
20 9 * * *    dcop kdesktop KBackgroundIface setWallpaper /tmp/astronomyPicOfDay/070925/zodiacal_beletsky.jpg 5

To install a cron just type "crontab a.job", to see it was installed type "crontab -l". Also you'll want to change the time to something pretty soon in this example I used 9:20AM. Now this is what comes to my e-mail: "ERROR: Couldn't attach to DCOP server!"

javaunixsolaris 09-28-2007 04:40 PM

So I guess I can't fully automate this program with CRON (yet...). Here is a cool script that will go to the website and change your background to the "Astronomy Picture of the Day".

Download: http://www.badgerpile.com/getAstronomyPicOfDay.sh
You may have to make sure it's executable,
Code:

$ chmod 777 getAstronomyPicOfDay.sh
then
Code:

$ ./getAstronomyPicOfDay.sh
should work.

THANKS NASA this web page rocks: http://antwrp.gsfc.nasa.gov/apod/archivepix.html

DavidisLin 11-29-2007 05:30 PM

crontab problem
 
the solution is to use the --user option in the cron tab because
cron assumes that there is no one logged in at the time or at least not you. so here is a version that will work:

Code:

dcop --user auser kdesktop KBackgroundIface setWallpaper /tmp/astronomyPicOfDay/070925/zodiacal_beletsky.jpg 5
replace auser with the user anem and it will work. ive tested it.

javaunixsolaris 12-01-2007 05:41 PM

Quote:

Originally Posted by DavidisLin (Post 2974980)
the solution is to use the --user option...

Yeah I found that out, and that's how the script works today. Go ahead and check it out (two posts up). Thanks.


All times are GMT -5. The time now is 11:00 PM.