DRY gsettings schema/key

This commit is contained in:
Isaiah Odhner 2023-07-17 22:36:27 -04:00
parent fece1c48c6
commit 5fd214182c

View File

@ -91,14 +91,14 @@ def set_wallpaper(file_loc: str, first_run: bool = True):
desktop_env = get_desktop_environment()
if desktop_env in ["gnome", "unity", "cinnamon"]:
uri = "'file://%s'" % file_loc
SCHEMA = "org.gnome.desktop.background"
KEY = "picture-uri"
try:
from gi.repository import Gio # type: ignore
SCHEMA = "org.gnome.desktop.background"
KEY = "picture-uri"
gsettings = Gio.Settings.new(SCHEMA) # type: ignore
gsettings.set_string(KEY, uri)
except Exception:
args = ["gsettings", "set", "org.gnome.desktop.background", "picture-uri", uri]
args = ["gsettings", "set", SCHEMA, KEY, uri]
subprocess.Popen(args)
elif desktop_env=="mate":
try: # MATE >= 1.6