Adding support for Cinnamon 5.4 and 5.8

This commit is contained in:
2023-07-08 16:39:51 +02:00
parent 11fa9e31c5
commit 52402aaaf4
2 changed files with 21 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
import gi, os, glob, json, shutil, enum, threading
import gi, os, glob, json, shutil, enum, threading, subprocess
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GdkPixbuf
@@ -11,9 +11,6 @@ IMAGE_EXTRACT_DIR = IMAGE_DIR + "extracted/"
IMAGE_SETS_DIR = IMAGE_DIR + "included_image_sets/"
IMAGE_SELECTED_DIR = IMAGE_DIR + "selected/"
PREF_PATH = os.path.expanduser("~") + \
"/.config/cinnamon/spices/cinnamon-dynamic-wallpaper@TobiZog/cinnamon-dynamic-wallpaper@TobiZog.json"
class Source(enum.Enum):
SELECTED = 0 # Load previous selected images
EXTRACT = 1 # Use a custom image set from a heic file
@@ -108,6 +105,19 @@ class ImageConfigurator:
self.image_source = Source.SELECTED
# Check for Cinnamon version
# With version 5.6+, the folder of the configuration file was changed
version = subprocess.check_output(["cinnamon", "--version"])
version = version.decode()
version = version[version.find(" "):version.rfind("\n")].strip()
if version.startswith("5.4"):
self.pref_path = os.path.expanduser("~") + \
"/.cinnamon/configs/cinnamon-dynamic-wallpaper@TobiZog/cinnamon-dynamic-wallpaper@TobiZog.json"
else:
self.pref_path = os.path.expanduser("~") + \
"/.config/cinnamon/spices/cinnamon-dynamic-wallpaper@TobiZog/cinnamon-dynamic-wallpaper@TobiZog.json"
# Load preferences
self.loadFromSettings()
@@ -128,7 +138,7 @@ class ImageConfigurator:
""" Load preferences from the Cinnamon preference file
"""
# Load the settings
with open(PREF_PATH, "r") as pref_file:
with open(self.pref_path, "r") as pref_file:
pref_data = json.load(pref_file)
@@ -167,7 +177,7 @@ class ImageConfigurator:
""" Save preferences to the Cinnamon preference file
"""
# Load the settings
with open(PREF_PATH, "r") as pref_file:
with open(self.pref_path, "r") as pref_file:
pref_data = json.load(pref_file)
@@ -185,7 +195,7 @@ class ImageConfigurator:
# Write the settings
with open(PREF_PATH, "w") as pref_file:
with open(self.pref_path, "w") as pref_file:
json.dump(pref_data, pref_file, separators=(',', ':'), indent=4)

View File

@@ -2,9 +2,11 @@
"uuid": "cinnamon-dynamic-wallpaper@TobiZog",
"name": "Cinnamon Dynamic Wallpaper",
"description": "Cinnamon extension for dynamic desktop backgrounds based on time and location",
"version": "1.0",
"version": "1.1",
"cinnamon-version": [
"5.6"
"5.4",
"5.6",
"5.8"
],
"max-instances": 1,
"url": "https://github.com/TobiZog/cinnamon-dynamic-wallpaper"