diff options
| author | Dylan Araps <[email protected]> | 2017-06-23 13:56:24 +1000 |
|---|---|---|
| committer | Dylan Araps <[email protected]> | 2017-06-23 13:56:24 +1000 |
| commit | 5481829a1299a7b341254a5875ca3973af3737e2 (patch) | |
| tree | 98bdb14c539f6a2e164006315c26018b11b4d248 /wal | |
| parent | General: Remove requirements.txt (diff) | |
| download | pywal-5481829a1299a7b341254a5875ca3973af3737e2.tar.xz pywal-5481829a1299a7b341254a5875ca3973af3737e2.zip | |
wallpaper: Reduce duplicate code.
Diffstat (limited to 'wal')
| -rwxr-xr-x | wal | 25 |
1 files changed, 12 insertions, 13 deletions
@@ -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.""" |