Skip to content

Commit c098674

Browse files
authored
Use XDG_CONFIG_HOME to store background config files instead of .cinnamon (#11177)
Changes in background settings: * If `user-folders.lst` is at the new place it will use that, else it will use the one in the old location. * When changed it will save into the new location, effectively orphaning it
1 parent 0fc32e2 commit c098674

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

files/usr/share/cinnamon/cinnamon-settings/modules/cs_backgrounds.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
BACKGROUND_COLLECTION_TYPE_DIRECTORY = "directory"
4444
BACKGROUND_COLLECTION_TYPE_XML = "xml"
4545

46+
CONFIG_FOLDER = os.path.join(GLib.get_user_config_dir(), 'cinnamon', 'backgrounds')
47+
OLD_CONFIG_FOLDER = os.path.expanduser("~/.cinnamon/backgrounds")
48+
USER_FOLDERS_FILE_NAME = 'user-folders.lst'
49+
4650
# even though pickle supports higher protocol versions, we want to version 2 because it's the latest
4751
# version supported by python2 which (at this time) is still used by older versions of Cinnamon.
4852
# When those versions are no longer supported, we can consider using a newer version.
@@ -340,7 +344,9 @@ def get_system_backgrounds(self):
340344

341345
def get_user_backgrounds(self):
342346
self.user_backgrounds = []
343-
path = os.path.expanduser("~/.cinnamon/backgrounds/user-folders.lst")
347+
path = os.path.join(CONFIG_FOLDER, USER_FOLDERS_FILE_NAME)
348+
old_path = os.path.join(OLD_CONFIG_FOLDER, USER_FOLDERS_FILE_NAME)
349+
path = path if os.path.exists(path) else old_path
344350
if os.path.exists(path):
345351
with open(path) as f:
346352
folders = f.readlines()
@@ -463,10 +469,10 @@ def remove_folder(self):
463469
break
464470

465471
def update_folder_list(self):
466-
path = os.path.expanduser("~/.cinnamon/backgrounds")
472+
path = CONFIG_FOLDER
467473
if not os.path.exists(path):
468474
os.makedirs(path, mode=0o755, exist_ok=True)
469-
path = os.path.expanduser("~/.cinnamon/backgrounds/user-folders.lst")
475+
path = os.path.join(CONFIG_FOLDER, USER_FOLDERS_FILE_NAME)
470476
if len(self.user_backgrounds) == 0:
471477
file_data = ""
472478
else:

0 commit comments

Comments
 (0)