mirror of
https://github.com/dylanaraps/pywal.git
synced 2024-11-29 11:24:03 +01:00
wallpaper: Reduce duplicate code.
This commit is contained in:
parent
b53b4dabb6
commit
5481829a12
25
wal
25
wal
@ -371,36 +371,35 @@ def get_desktop_env():
|
||||
return "MATE"
|
||||
|
||||
|
||||
def xfconf(path, img):
|
||||
"""Call xfconf to set the wallpaper on XFCE."""
|
||||
subprocess.Popen(["xfconf-query", "--channel", "xfce4-desktop",
|
||||
"--property", path, "--set", img])
|
||||
|
||||
|
||||
def set_desktop_wallpaper(desktop, img):
|
||||
"""Set the wallpaper for the desktop environment."""
|
||||
desktop = str(desktop).lower()
|
||||
|
||||
if "xfce" in desktop or "xubuntu" in desktop:
|
||||
subprocess.Popen(["xfconf-query", "--channel", "xfce4-desktop",
|
||||
"--property",
|
||||
"/backdrop/screen0/monitor0/image-path",
|
||||
"--set", img])
|
||||
|
||||
# XFCE requires two commands since they differ between versions.
|
||||
subprocess.Popen(["xfconf-query", "--channel", "xfce4-desktop",
|
||||
"--property",
|
||||
"/backdrop/screen0/monitor0/workspace0/last-image",
|
||||
"--set", img])
|
||||
xfconf("/backdrop/screen0/monitor0/image-path", img)
|
||||
xfconf("/backdrop/screen0/monitor0/workspace0/last-image", img)
|
||||
|
||||
elif "muffin" in desktop or "cinnamon" in desktop:
|
||||
subprocess.Popen(["gsettings", "set",
|
||||
"org.cinnamon.desktop.background",
|
||||
"picture-uri", "file:///" + img])
|
||||
|
||||
elif "mate" in desktop:
|
||||
subprocess.Popen(["gsettings", "set", "org.mate.background",
|
||||
"picture-filename", img])
|
||||
|
||||
elif "gnome" in desktop:
|
||||
subprocess.Popen(["gsettings", "set",
|
||||
"org.gnome.desktop.background",
|
||||
"picture-uri", "file:///" + img])
|
||||
|
||||
elif "mate" in desktop:
|
||||
subprocess.Popen(["gsettings", "set", "org.mate.background",
|
||||
"picture-filename", img])
|
||||
|
||||
|
||||
def set_wallpaper(img):
|
||||
"""Set the wallpaper."""
|
||||
|
Loading…
Reference in New Issue
Block a user