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"
|
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):
|
def set_desktop_wallpaper(desktop, img):
|
||||||
"""Set the wallpaper for the desktop environment."""
|
"""Set the wallpaper for the desktop environment."""
|
||||||
desktop = str(desktop).lower()
|
desktop = str(desktop).lower()
|
||||||
|
|
||||||
if "xfce" in desktop or "xubuntu" in desktop:
|
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.
|
# XFCE requires two commands since they differ between versions.
|
||||||
subprocess.Popen(["xfconf-query", "--channel", "xfce4-desktop",
|
xfconf("/backdrop/screen0/monitor0/image-path", img)
|
||||||
"--property",
|
xfconf("/backdrop/screen0/monitor0/workspace0/last-image", img)
|
||||||
"/backdrop/screen0/monitor0/workspace0/last-image",
|
|
||||||
"--set", img])
|
|
||||||
|
|
||||||
elif "muffin" in desktop or "cinnamon" in desktop:
|
elif "muffin" in desktop or "cinnamon" in desktop:
|
||||||
subprocess.Popen(["gsettings", "set",
|
subprocess.Popen(["gsettings", "set",
|
||||||
"org.cinnamon.desktop.background",
|
"org.cinnamon.desktop.background",
|
||||||
"picture-uri", "file:///" + img])
|
"picture-uri", "file:///" + img])
|
||||||
|
|
||||||
elif "mate" in desktop:
|
|
||||||
subprocess.Popen(["gsettings", "set", "org.mate.background",
|
|
||||||
"picture-filename", img])
|
|
||||||
|
|
||||||
elif "gnome" in desktop:
|
elif "gnome" in desktop:
|
||||||
subprocess.Popen(["gsettings", "set",
|
subprocess.Popen(["gsettings", "set",
|
||||||
"org.gnome.desktop.background",
|
"org.gnome.desktop.background",
|
||||||
"picture-uri", "file:///" + img])
|
"picture-uri", "file:///" + img])
|
||||||
|
|
||||||
|
elif "mate" in desktop:
|
||||||
|
subprocess.Popen(["gsettings", "set", "org.mate.background",
|
||||||
|
"picture-filename", img])
|
||||||
|
|
||||||
|
|
||||||
def set_wallpaper(img):
|
def set_wallpaper(img):
|
||||||
"""Set the wallpaper."""
|
"""Set the wallpaper."""
|
||||||
|
Loading…
Reference in New Issue
Block a user