Skip to content

Commit e314591

Browse files
authored
Release v3.2
Release date: March 24, 2024
2 parents 0076d47 + edc352b commit e314591

File tree

11 files changed

+526
-132
lines changed

11 files changed

+526
-132
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,5 +159,5 @@ You can send an issue on GitHub, or if you are not registered on GitHub, you can
159159
- Build with Flatpak builder (beta version) ⚠️**UNSTABLE**⚠️
160160
```
161161
git clone https://github.com/vikdevelop/SaveDesktop && cd SaveDesktop && flatpak-builder build *.yaml --install --user
162-
# Maybe you will need to install org.gnome.Sdk (version 44) with flatpak
162+
# Maybe you will need to install org.gnome.Sdk (latest version) with flatpak
163163
```

flatpak/io.github.vikdevelop.SaveDesktop.gschema.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,9 @@
8686
<default>false</default>
8787
<summary>Manually sync</summary>
8888
</key>
89+
<key name="disabled-flatpak-apps-data" type="as">
90+
<default>[]</default>
91+
<summary>Select, what Flatpak applications data will be saved</summary>
92+
</key>
8993
</schema>
9094
</schemalist>

flatpak/io.github.vikdevelop.SaveDesktop.metainfo.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@
7373
</branding>
7474

7575
<releases>
76+
<release version="3.2" date="2024-03-24">
77+
<description>
78+
<ul>
79+
<li>Added option for selecting what Flatpak applications data will be included in the configuration archive; just click on the button next to the User data of installed Flatpak apps switch</li>
80+
<li>Improved displaying status about saving and importing configuration</li>
81+
<li>From now on, periodic saving will take place only after the first login on a given day, not after further logins on the same day</li>
82+
</ul>
83+
</description>
84+
</release>
7685
<release version="3.1" date="2024-02-02">
7786
<description>
7887
<ul>

flatpak/symbolic-icons/done.svg

Lines changed: 1 addition & 0 deletions
Loading

io.github.vikdevelop.SaveDesktop.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ modules:
6969
- install -D -t /app/share/icons/hicolor/128x128/apps flatpak/symbolic-icons/exclamation_mark.png
7070
- install -D -t /app/share/icons/hicolor/128x128/apps flatpak/symbolic-icons/desktop-symbolic.svg
7171
- install -D -t /app/share/icons/hicolor/128x128/apps flatpak/symbolic-icons/list-view.png
72+
- install -D -t /app/share/icons/hicolor/128x128/apps flatpak/symbolic-icons/done.svg
7273
- install -D -t /app/share/metainfo flatpak/io.github.vikdevelop.SaveDesktop.metainfo.xml
7374
- install -D -t /app/share/glib-2.0/schemas flatpak/io.github.vikdevelop.SaveDesktop.gschema.xml
7475
- glib-compile-schemas /app/share/glib-2.0/schemas

snapcraft.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ parts:
7575
install -D -t $CRAFT_PART_INSTALL/usr/share/icons/hicolor/128x128/apps $CRAFT_PART_SRC/flatpak/symbolic-icons/exclamation_mark.png
7676
install -D -t $CRAFT_PART_INSTALL/usr/share/icons/hicolor/128x128/apps $CRAFT_PART_SRC/flatpak/symbolic-icons/desktop-symbolic.svg
7777
install -D -t $CRAFT_PART_INSTALL/usr/share/icons/hicolor/128x128/apps $CRAFT_PART_SRC/flatpak/symbolic-icons/list-view.png
78+
install -D -t $CRAFT_PART_INSTALL/usr/share/icons/hicolor/128x128/apps $CRAFT_PART_SRC/flatpak/symbolic-icons/done.svg
7879
install -D -t $CRAFT_PART_INSTALL/usr/share/metainfo $CRAFT_PART_SRC/flatpak/io.github.vikdevelop.SaveDesktop.metainfo.xml
7980
install -D -t $CRAFT_PART_INSTALL/usr/share/glib-2.0/schemas $CRAFT_PART_SRC/flatpak/io.github.vikdevelop.SaveDesktop.gschema.xml
8081
glib-compile-schemas $CRAFT_PART_INSTALL/usr/share/glib-2.0/schemas

src/config.py

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from gi.repository import GLib, Gio
55
from localization import _, CACHE, DATA, home, system_dir, flatpak, snap
66
import argparse
7+
import shutil
78

89
parser = argparse.ArgumentParser()
910
parser.add_argument("-s", "--save", help="Save the current configuration", action="store_true")
@@ -36,37 +37,81 @@
3637
settings = Gio.Settings.new_with_path("io.github.vikdevelop.SaveDesktop", "/io/github/vikdevelop/SaveDesktop/")
3738
cache_replacing = f'{CACHE}'
3839
config = cache_replacing.replace("cache/tmp", "config/glib-2.0/settings")
40+
flatpak_app_data = settings["disabled-flatpak-apps-data"]
3941

4042
class Save:
4143
def __init__(self):
44+
print("saving settings from the Dconf database")
4245
os.system("dconf dump / > ./dconf-settings.ini")
43-
#os.system('cp -R {home}/.config/dconf/user ./')
46+
print("saving Gtk settings")
4447
os.system(f'cp -R {home}/.config/gtk-4.0 ./')
4548
os.system(f'cp -R {home}/.config/gtk-3.0 ./')
4649
if settings["save-backgrounds"] == True:
50+
print("saving backgrounds")
4751
os.system(f'cp -R {home}/.local/share/backgrounds ./')
4852
if settings["save-icons"] == True:
53+
print("saving icons")
4954
os.system(f'cp -R {home}/.local/share/icons ./')
5055
os.system(f'cp -R {home}/.icons ./')
5156
if settings["save-themes"] == True:
57+
print("saving themes")
5258
os.system(f'cp -R {home}/.themes ./')
5359
if settings["save-fonts"] == True:
60+
print("saving fonts")
5461
os.system(f'cp -R {home}/.fonts ./')
5562
if settings["save-desktop-folder"] == True:
63+
print("saving desktop folder")
5664
if " " in GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP):
5765
desktop_with_spaces = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP)
5866
desktop_without_spaces = desktop_with_spaces.replace(" ", "*")
5967
else:
6068
desktop_without_spaces = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP)
6169
os.system(f'cp -R {desktop_without_spaces} ./Desktop/ ')
6270
if settings["save-installed-flatpaks"] == True:
71+
print("saving list of installed Flatpak apps")
6372
os.system('sh /app/backup_flatpaks.sh')
6473
if settings["save-flatpak-data"] == True:
74+
print("saving user data of installed Flatpak apps")
75+
blst = settings["disabled-flatpak-apps-data"]
76+
# convert GSettings property to list
77+
blist = blst
78+
# add io.github.vikdevelop.SaveDesktop to blacklist, because during saving configuration the cache folder is too large
79+
blist += ["io.github.vikdevelop.SaveDesktop"]
80+
blacklist = blist
81+
82+
# set destination dir
6583
if os.path.exists(f"{CACHE}/save_config"):
66-
os.system(f'cd {home}/.var/app && mkdir {CACHE}/save_config/app && cp -r `ls -A | grep -v "io.github.vikdevelop.SaveDesktop"` {CACHE}/save_config/app/')
84+
os.makedirs(f"{CACHE}/save_config/app", exist_ok=True)
85+
destdir = f"{CACHE}/save_config/app"
6786
elif os.path.exists(f"{CACHE}/periodic_saving"):
68-
os.system(f'cd {home}/.var/app && mkdir {CACHE}/periodic_saving/app && cp -r `ls -A | grep -v "io.github.vikdevelop.SaveDesktop"` {CACHE}/periodic_saving/app/')
87+
os.makedirs(f"{CACHE}/periodic_saving/app", exist_ok=True)
88+
destdir = f"{CACHE}/periodic_saving/app"
89+
90+
# copy Flatpak apps data
91+
for item in os.listdir(f"{home}/.var/app"):
92+
if item not in blacklist:
93+
source_path = os.path.join(f"{home}/.var/app", item)
94+
destination_path = os.path.join(destdir, item)
95+
if os.path.isdir(source_path):
96+
try:
97+
shutil.copytree(source_path, destination_path)
98+
except Exception as e:
99+
print(f"Error copying directory {source_path}: {e}")
100+
else:
101+
try:
102+
shutil.copy2(source_path, destination_path)
103+
except Exception as e:
104+
print(f"Error copying file {source_path}: {e}")
105+
106+
# save user data except for the cache of the SaveDesktop app if the app is not in the "disabled-flatpak-apps-data" key of the GSettings database
107+
if not "io.github.vikdevelop.SaveDesktop" in flatpak_app_data:
108+
os.makedirs(f"{destdir}/io.github.vikdevelop.SaveDesktop", exist_ok=True)
109+
os.chdir(f"{home}/.var/app/io.github.vikdevelop.SaveDesktop")
110+
os.system(f"cp -R ./config {destdir}/io.github.vikdevelop.SaveDesktop/")
111+
os.system(f"cp -R ./data {destdir}/io.github.vikdevelop.SaveDesktop/")
112+
os.chdir(f"{CACHE}/save_config")
69113

114+
print("saving desktop environment configuration files")
70115
# Save configs on individual desktop environments
71116
if environment == 'GNOME':
72117
os.system(f"cp -R {home}/.local/share/gnome-background-properties ./")
@@ -115,6 +160,7 @@ def __init__(self):
115160
os.system(f"cp -R {home}/.local/share/wallpapers ./xdg-data/")
116161
if settings["save-extensions"] == True:
117162
os.system(f"cp -R {home}/.local/share/plasma ./xdg-data/")
163+
print("creating configuration archive")
118164
os.system(f"tar --exclude='cfg.sd.tar.gz' --gzip -cf cfg.sd.tar.gz ./")
119165
if os.path.exists(f"{CACHE}/.filedialog.json"):
120166
with open(f"{CACHE}/.filedialog.json") as j:
@@ -125,7 +171,11 @@ def __init__(self):
125171
if not settings["periodic-import"] == "Never2":
126172
file = os.path.basename(j["recent_file"])
127173
os.system(f"cp -R ./cfg.sd.tar.gz {DATA}/synchronization/{file}")
174+
print("moving the configuration archive to the user-defined directory")
128175
os.system(f"mv ./cfg.sd.tar.gz {j['recent_file']}")
176+
if os.path.exists(f"{CACHE}/save_config"):
177+
os.system("echo > done_gui")
178+
print("THE CONFIGURATION HAS BEEN SAVED SUCCESSFULLY!")
129179

130180
class Import:
131181
def __init__(self):
@@ -135,6 +185,7 @@ def __init__(self):
135185
os.system("tar -xf %s ./" % j["import_file"])
136186
if not os.path.exists("{}/.config".format(home)):
137187
os.system(f"mkdir {home}/.config/")
188+
print("importing settings from the Dconf database")
138189
if os.path.exists("user"):
139190
os.system(f"cp -R ./user {home}/.config/dconf/")
140191
else:
@@ -143,22 +194,30 @@ def __init__(self):
143194
else:
144195
os.system("echo user-db:user > temporary-profile")
145196
os.system('DCONF_PROFILE="$(pwd)/temporary-profile" dconf load / < dconf-settings.ini')
197+
print("importing list of installed Flatpak apps (them will be installed after the next login)")
146198
os.system(f'cp ./installed_flatpaks.sh {DATA}/')
147199
os.system(f'cp ./installed_user_flatpaks.sh {DATA}/')
200+
print("importing icons")
148201
os.system(f'cp -R ./icons {home}/.local/share/')
149-
os.system(f'cp -R ./.themes {home}/')
150202
os.system(f'cp -R ./.icons {home}/')
203+
print("importing themes")
204+
os.system(f'cp -R ./.themes {home}/')
205+
print("importing backgrounds")
151206
os.system(f'cp -R ./backgrounds {home}/.local/share/')
207+
print("importing fonts")
152208
os.system(f'cp -R ./.fonts {home}/')
209+
print("importing Gtk settings")
153210
os.system(f'cp -R ./gtk-4.0 {home}/.config/')
154211
os.system(f'cp -R ./gtk-3.0 {home}/.config/')
212+
print("importing desktop directory")
155213
os.system(f'cp -R ./Desktop/* {GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP)}/')
156214
if os.path.exists(f'{CACHE}/import_config/app'):
157215
with open(f"copying_flatpak_data", "w") as c:
158216
c.write("copying flatpak data ...")
159217
elif os.path.exists(f'{CACHE}/syncing/app'):
160218
with open(f"copying_flatpak_data", "w") as c:
161219
c.write("copying flatpak data ...")
220+
print("importing desktop environment configuration files")
162221
# Apply configs for individual desktop environments
163222
if environment == 'GNOME':
164223
os.system(f'cp -R ./gnome-background-properties {home}/.local/share/')
@@ -199,9 +258,10 @@ def __init__(self):
199258
os.chdir("%s/import_config" % CACHE)
200259
os.chdir('xdg-data')
201260
os.system(f'cp -R ./ {home}/.local/share/')
202-
if not snap:
261+
if flatpak:
203262
self.create_flatpak_desktop()
204263
os.system(f"echo > {CACHE}/import_config/done")
264+
print("THE CONFIGURATION HAS BEEN IMPORTED SUCCESSFULLY!")
205265

206266
# Create desktop file for install Flatpaks from list
207267
def create_flatpak_desktop(self):

src/localization.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@
2424
s.close()
2525

2626
# Set application version, and icon
27-
v = "3.1.2"
27+
v = "3.2"
2828
icon = "io.github.vikdevelop.SaveDesktop"
29-
rel_notes = "<p>Edited application data for passing the Flathub guidelines</p>"
29+
rel_notes = "<ul>\
30+
<li>Added option for selecting what Flatpak applications data will be included in the configuration archive; just click on the button next to the \"User data of installed Flatpak apps\" switch</li>\
31+
<li>Improved displaying status about saving and importing configuration</li>\
32+
<li>From now on, periodic saving will take place only after the first login on a given day, not after further logins on the same day</li>\
33+
</ul>"
3034

3135
flatpak = os.path.exists("/.flatpak-info")
3236
snap = os.environ.get('SNAP_NAME', '') == 'savedesktop'

0 commit comments

Comments
 (0)