77import subprocess
88import urllib .parse
99
10- from . settings import CACHE_DIR , HOME , OS
11- from . import util
10+ import settings
11+ import util
1212
1313
1414def get_desktop_env ():
@@ -67,7 +67,7 @@ def set_wm_wallpaper(img):
6767
6868 elif shutil .which ("hsetroot" ):
6969 util .disown (["hsetroot" , "-fill" , img ])
70-
70+
7171 elif shutil .which ("nitrogen" ):
7272 util .disown (["nitrogen" , "--set-zoom-fill" , img ])
7373
@@ -91,7 +91,7 @@ def set_wm_wallpaper(img):
9191def set_desktop_wallpaper (desktop , img ):
9292 """Set the wallpaper for the desktop environment."""
9393 desktop = str (desktop ).lower ()
94-
94+
9595 if "xfce" in desktop or "xubuntu" in desktop :
9696 xfconf (img )
9797
@@ -115,16 +115,26 @@ def set_desktop_wallpaper(desktop, img):
115115 elif "awesome" in desktop :
116116 util .disown (["awesome-client" ,
117117 "require('gears').wallpaper.maximized('{img}')"
118- .format (** locals ())])
119-
118+ .format (** locals ())])
119+
120+ elif "kde" in desktop :
121+ string = """
122+ var allDesktops = desktops();for (i=0;i<allDesktops.length;i++){
123+ d = allDesktops[i];d.wallpaperPlugin = "org.kde.image";
124+ d.currentConfigGroup = Array("Wallpaper", "org.kde.image", "General");
125+ d.writeConfig("Image", "%s")};
126+ """
127+ util .disown (["qdbus" , "org.kde.plasmashell" , "/PlasmaShell" , "org.kde.PlasmaShell.evaluateScript" ,
128+ string % img ])
129+
120130 else :
121131 set_wm_wallpaper (img )
122132
123133
124134def set_mac_wallpaper (img ):
125135 """Set the wallpaper on macOS."""
126136 db_file = "Library/Application Support/Dock/desktoppicture.db"
127- db_path = os .path .join (HOME , db_file )
137+ db_path = os .path .join (settings . HOME , db_file )
128138 img_dir , _ = os .path .split (img )
129139
130140 # Clear the existing picture data and write the image paths
@@ -163,19 +173,19 @@ def change(img):
163173
164174 desktop = get_desktop_env ()
165175
166- if OS == "Darwin" :
176+ if settings . OS == "Darwin" :
167177 set_mac_wallpaper (img )
168178
169- elif OS == "Windows" :
179+ elif settings . OS == "Windows" :
170180 set_win_wallpaper (img )
171181
172182 else :
173183 set_desktop_wallpaper (desktop , img )
174184
175- logging .info ("Set the new wallpaper." )
185+ logging .info ("Desktop is " + desktop )
176186
177187
178- def get (cache_dir = CACHE_DIR ):
188+ def get (cache_dir = settings . CACHE_DIR ):
179189 """Get the current wallpaper."""
180190 current_wall = os .path .join (cache_dir , "wal" )
181191
0 commit comments