Skip to content

Commit

Permalink
keep favourite images #237
Browse files Browse the repository at this point in the history
  • Loading branch information
neffo committed Jul 28, 2024
1 parent 0c6d259 commit e04dd19
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Binary file modified schemas/gschemas.compiled
Binary file not shown.
6 changes: 6 additions & 0 deletions schemas/org.gnome.shell.extensions.bingwallpaper.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
<description>Save disk space</description>
</key>

<key name="keep-favourites" type="b">
<default>True</default>
<summary>Keep previous wallpapers if they are favourites</summary>
<description>Sensible default behaivour</description>
</key>

<key name="previous-days" type="i">
<default>8</default>
<summary>Number of days to keep wallpapers</summary>
Expand Down
4 changes: 3 additions & 1 deletion utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,14 +550,16 @@ export function deleteImage(to_delete) {
// add image to persistant list so we can delete it later (in chronological order), delete the oldest image (if user wants this)
export function purgeImages(settings) {
let deletepictures = settings.get_boolean('delete-previous');
let keepfavorites = settings.get_boolean('keep-favourites');
if (deletepictures === false)
return;
let imagelist = imageListSortByDate(getImageList(settings));
let maxpictures = settings.get_int('previous-days');
let origlength = imagelist.length;
while (imagelist.length > maxpictures) {
var to_delete = imagelist.shift(); // get the first (oldest item from the list)
if (deletepictures && to_delete != '') {
var ok_to_delete = keepfavorites && (to_delete.favourite && to_delete.favourite === true);
if (deletepictures && to_delete != '' && ok_to_delete) {
let imageFilename = imageToFilename(settings, to_delete);
BingLog('deleting '+imageFilename);
deleteImage(imageFilename);
Expand Down

0 comments on commit e04dd19

Please sign in to comment.