def getLocalWallpaper(): "Returns local wallpaper using dcop" # Create a dcop object: client = DCOPClient() if not client.attach(): return None # Get Wallpaper: background = DCOPObj("kdesktop", client, "KBackgroundIface") ok, wallpaper = background.currentWallpaper(0) if ok: return wallpaper else: return None
def setWallpaper(path): "Changes current wallpaper with the new one" # Copy file to wallpapers dir: wallpapersdir = os.path.expanduser("~/.kde/share/wallpapers") if not (os.path.isdir(wallpapersdir)): os.makedirs(wallpapersdir) newpath = os.path.join(wallpapersdir, os.path.basename(path)) shutil.copyfile(path, newpath) # Create a dcop object: client = DCOPClient() if not client.attach(): raise WallpaperError, "Wallpaper cannot be changed" # Set Wallpaper: background = DCOPObj("kdesktop", client, "KBackgroundIface") ok, wallpaper = background.setWallpaper(QString(unicode(newpath)), 6) # 6: Scaled if not ok: raise WallpaperError, "Wallpaper cannot be changed"
def openComposer(to='', cc='', bcc='', subject='', message=''): interfaces = [('kmail', 'default'), ('kontact', 'KMailIface')] client = DCOPClient() client.attach() done = False for app, part in interfaces: obj = DCOPObj(app, client, part) try: obj.openComposer(to, cc, bcc, qstr(subject), qstr(message), False, KURL()) done = True break except TypeError: pass return done