small refactor + fixed dbus command path
This commit is contained in:
parent
e4d8bccdab
commit
33b1df8b6b
@ -18,6 +18,28 @@ def find_all_images(path):
|
||||
|
||||
return images
|
||||
|
||||
def handle_feh(wallpapers):
|
||||
cmd = "/usr/bin/feh --no-fehbg --bg-fill "
|
||||
for wallpaper in wallpapers:
|
||||
cmd += str(f"{wallpaper} ")
|
||||
subprocess.call(cmd, shell=True)
|
||||
|
||||
def handle_plasma(wallpapers):
|
||||
fuckingGarbageJS = """
|
||||
var allDesktops = desktops();
|
||||
"""
|
||||
for wallpaper in wallpapers:
|
||||
wallpaperIndex = wallpapers.index(wallpaper)
|
||||
fuckingGarbageJS += f"""allDesktops[{wallpaperIndex}].wallpaperPlugin = "org.kde.image";
|
||||
allDesktops[{wallpaperIndex}].currentConfigGroup = Array("Wallpaper", "org.kde.image", "General");
|
||||
allDesktops[{wallpaperIndex}].writeConfig("Image", "file://{wallpaper}");
|
||||
"""
|
||||
cmd = f"/usr/bin/qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript '{fuckingGarbageJS}'"
|
||||
subprocess.call(cmd, shell=True)
|
||||
|
||||
def handle_gnome(wallpapers):
|
||||
raise NotImplementedError
|
||||
|
||||
conf_file = f"{os.environ['HOME']}/.config/wallpaperctl/wallpaperctl.ini"
|
||||
|
||||
# Initialize config file
|
||||
@ -61,28 +83,13 @@ for mon in monitors:
|
||||
|
||||
match WALLPAPER_ENGINE:
|
||||
case 'feh':
|
||||
cmd = "/usr/bin/feh --no-fehbg --bg-fill "
|
||||
for wallpaper in wallpapers:
|
||||
cmd += str(f"{wallpaper} ")
|
||||
subprocess.call(cmd, shell=True)
|
||||
handle_feh(wallpapers)
|
||||
|
||||
case 'plasma':
|
||||
# Write code to handle changing wallpapers on plasmashell
|
||||
fuckingGarbageJS = """
|
||||
var allDesktops = desktops();
|
||||
"""
|
||||
for wallpaper in wallpapers:
|
||||
wallpaperIndex = wallpapers.index(wallpaper)
|
||||
fuckingGarbageJS += f"""allDesktops[{wallpaperIndex}].wallpaperPlugin = "org.kde.image";
|
||||
allDesktops[{wallpaperIndex}].currentConfigGroup = Array("Wallpaper", "org.kde.image", "General");
|
||||
allDesktops[{wallpaperIndex}].writeConfig("Image", "file://{wallpaper}");
|
||||
"""
|
||||
cmd = f"qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript '{fuckingGarbageJS}'"
|
||||
subprocess.call(cmd, shell=True)
|
||||
handle_plasma(wallpapers)
|
||||
|
||||
case 'gnome':
|
||||
# Write code to handle changing wallpapers on gnomeshell
|
||||
cmd = "ls"
|
||||
pass
|
||||
handle_gnome(wallpapers)
|
||||
|
||||
case _:
|
||||
print(f"Wallpaper engine {WALLPAPER_ENGINE} is not supported")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user