Skip to content

Commit dcc137b

Browse files
Merge pull request #22 from mylinuxforwork/21-move-dotfilesjson
dotfiles.json moved to XDG-HOME-CONFIG
2 parents 5c135b2 + 2c59b5c commit dcc137b

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/_settings.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#
1616
# SPDX-License-Identifier: GPL-3.0-or-later
1717

18-
import os, pathlib, logging
18+
import os, shutil, pathlib, logging
1919
from gi.repository import Gtk, Gdk, Gio, GLib, Adw
2020

2121
# App Id
@@ -32,6 +32,7 @@
3232
prepared_folder_name = "prepared"
3333
backup_folder_name = "backup"
3434
dotfiles_folder_name = ".mydotfiles"
35+
dotfiles_json_name = "dotfiles.json"
3536

3637
# Folders
3738
home_folder = GLib.get_home_dir() + "/"
@@ -112,6 +113,12 @@ def run_setup():
112113
pathlib.Path(config_folder).mkdir(parents=True, exist_ok=True)
113114
printLog(config_folder + " created (if not exists)")
114115

116+
# Update from older versions
117+
# Move dotfiles.json
118+
if os.path.exists(get_installed_dotfiles_folder() + dotfiles_json_name):
119+
shutil.move(get_installed_dotfiles_folder() + dotfiles_json_name, config_folder)
120+
printLog("Legacy " + dotfiles_json_name + " found. Moved to " + config_folder)
121+
115122
# Print log to the terminal
116123
def printLog(msg,cat='m'):
117124
match cat:

src/classes/installation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def install_dotfiles(self):
7777
# Write dotfiles config file to dotfiles folder
7878
dotfiles_json = {}
7979
dotfiles_json["active"] = self.props.id
80-
with open(get_installed_dotfiles_folder() + 'dotfiles.json', 'w', encoding='utf-8') as f:
80+
with open(config_folder + dotfiles_json_name, 'w', encoding='utf-8') as f:
8181
json.dump(dotfiles_json, f, ensure_ascii=False, indent=4)
8282
printLog(self.props.id + " set as active dotfiles")
8383

src/classes/loadconfiguration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ def load_installed_dotfiles(self):
252252
item.source = dot_json["source"]
253253
item.subfolder = dot_json["subfolder"]
254254

255-
if os.path.exists(get_installed_dotfiles_folder() + "dotfiles.json"):
256-
installed_json = json.load(open(get_installed_dotfiles_folder() + "/dotfiles.json"))
255+
if os.path.exists(config_folder + dotfiles_json_name):
256+
installed_json = json.load(open(config_folder + dotfiles_json_name))
257257
if installed_json["active"] == dot_json["id"]:
258258
item.active = True
259259

0 commit comments

Comments
 (0)