Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build
dist
*.egg-info
9 changes: 9 additions & 0 deletions wpreddit/wallpaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import re
import shutil
import sys
import dbus
from subprocess import check_call, check_output, CalledProcessError

from wpreddit import config
Expand Down Expand Up @@ -58,6 +59,13 @@ def linux_wallpaper():
elif check_de(de, ["mate"]):
check_call(["gsettings", "set", "org.mate.background", "picture-filename",
"'%s'" % path])
elif check_de(de, ["plasma"]):
jscript = f"""for (let desktop of desktops()) {{
Object.assign(desktop, {{ wallpaperPlugin: 'org.kde.image', currentConfigGroup: ['Wallpaper', 'org.kde.image', 'General'] }});
desktop.writeConfig('Image', 'file://{save_wallpaper()}'); }}"""
plasma = dbus.Interface(dbus.SessionBus().get_object('org.kde.plasmashell', '/PlasmaShell'), dbus_interface='org.kde.PlasmaShell')
plasma.evaluateScript(jscript)

elif check_de(de, ["xfce", "xubuntu"]):
# Light workaround here, just need to toggle the wallpaper from null to the original filename
# xfconf props aren't 100% consistent so light workaround for that too
Expand Down Expand Up @@ -119,3 +127,4 @@ def save_wallpaper():
f.write('\n' + 'wallpaper' + str(wpcount) + ': ' + title)

print("Current wallpaper saved to " + newpath)
return newpath