mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-06-18 15:46:38 +02:00
Merge pull request #395 from ellisgeek/master
Add support for setting wallpaper in xfce > 4.12
This commit is contained in:
commit
3cedb38053
@ -2,6 +2,7 @@
|
|||||||
import ctypes
|
import ctypes
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
@ -39,10 +40,21 @@ def get_desktop_env():
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def xfconf(path, img):
|
def xfconf(img):
|
||||||
"""Call xfconf to set the wallpaper on XFCE."""
|
"""Call xfconf to set the wallpaper on XFCE."""
|
||||||
util.disown(["xfconf-query", "--channel", "xfce4-desktop",
|
xfconf_re = re.compile(
|
||||||
"--property", path, "--set", img])
|
r"^/backdrop/screen\d/monitor(?:0|\w*)/"
|
||||||
|
r"(?:(?:image-path|last-image)|workspace\d/last-image)$",
|
||||||
|
flags=re.M
|
||||||
|
)
|
||||||
|
xfconf_data = subprocess.check_output(
|
||||||
|
["xfconf-query", "--channel", "xfce4-desktop", "--list"],
|
||||||
|
stderr=subprocess.DEVNULL
|
||||||
|
).decode('utf8')
|
||||||
|
paths = xfconf_re.findall(xfconf_data)
|
||||||
|
for path in paths:
|
||||||
|
util.disown(["xfconf-query", "--channel", "xfce4-desktop",
|
||||||
|
"--property", path, "--set", img])
|
||||||
|
|
||||||
|
|
||||||
def set_wm_wallpaper(img):
|
def set_wm_wallpaper(img):
|
||||||
@ -75,9 +87,7 @@ def set_desktop_wallpaper(desktop, img):
|
|||||||
desktop = str(desktop).lower()
|
desktop = str(desktop).lower()
|
||||||
|
|
||||||
if "xfce" in desktop or "xubuntu" in desktop:
|
if "xfce" in desktop or "xubuntu" in desktop:
|
||||||
# XFCE requires two commands since they differ between versions.
|
xfconf(img)
|
||||||
xfconf("/backdrop/screen0/monitor0/image-path", img)
|
|
||||||
xfconf("/backdrop/screen0/monitor0/workspace0/last-image", img)
|
|
||||||
|
|
||||||
elif "muffin" in desktop or "cinnamon" in desktop:
|
elif "muffin" in desktop or "cinnamon" in desktop:
|
||||||
util.disown(["gsettings", "set",
|
util.disown(["gsettings", "set",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user