neffo / bing-wallpaper-gnome-extension

GNOME shell extension that syncs your desktop & lock screen wallpaper to Microsoft Bing's Image of the Day.
https://extensions.gnome.org/extension/1262/bing-wallpaper-changer/
GNU General Public License v3.0
299 stars 56 forks source link

[FEATURE REQUEST] Add a way to delete downloaded images after a certain time period #244

Open loxoron218 opened 2 months ago

loxoron218 commented 2 months ago

Describe the requested feature The README.md of the extension advertises the feature: "Optionally delete old images after a week, or you can keep (and curate) them forever". Unfortunately, I'm not able to find any option to delete the downloaded wallpapers from Bing after a week, nor the extension deletes them automatically. Moreover, the trash icon on the tray menu only deletes the current wallpaper, not the other ones. So I guess this is a FEATURE and a BUG report.

Screenshots I deleted all the images from the local folder and clicked on the Update now button from the tray. Here can you see that I have ten of them right after that. Bildschirmfoto vom 2024-09-13 12-18-03

Desktop (please complete the following information):

Additional context This feature would be very helpful for me, since I'm running the extension on a Laptop with limited space and without it I'm "forced" to delete the pictures every once in a while manually.

Thanks for your amazing job!

neffo commented 2 months ago

Currently this is a hidden feature (not exposed in the quick settings, the prefs or the debug options). It is enabled through these keys:

    <key name="delete-previous" type="b">
      <default>false</default>
        <summary>Delete previous wallpapers</summary>
        <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>
      <description>Delete wallpapers after this number of days</description>
    </key>

I removed some of these options when I migrated the extension to Adwaita, but you can access them with gsettings (I acknowledge this is very fiddly).

$ gsettings --schemadir $HOME/.local/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/schemas get org.gnome.shell.extensions.bingwallpaper delete-previous
> false

To turn this on:

$ gsettings --schemadir $HOME/.local/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/schemas set org.gnome.shell.extensions.bingwallpaper delete-previous true

Then you can set the number of days to delete images after (default is 8, don't go lower than this):

$ gsettings --schemadir $HOME/.local/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/schemas set org.gnome.shell.extensions.bingwallpaper previous-days 14

By default if you favorite an image it won't be deleted ('keep-favourites' setting): image

Some of this code hasn't been tested in a while so your mileage my vary. If you encounter bugs, let me know. Images will be cleaned up at next refresh (which you can force with 'Refresh Now').

neffo commented 2 months ago

I deleted all the images from the local folder and clicked on the Update now button from the tray. Here can you see that I have ten of them right after that.

Yes, by default the extension tries to catch up with missed images for up to 8 days. This is helpful if you don't have your PC or laptop on the whole time, but interacts with deleting recent images. (Essentially it'll download images and then delete them again.) I've just pushed a change to version 50 to handle this, but I will need to test it.

And thanks for creating the Github issue. I don't necessarily know what people use feature wise, so asking helps me keep this functionality ... functional.

loxoron218 commented 2 months ago

Thanks a lot! I will be testing these settings from now on:

gsettings --schemadir $HOME/.local/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/schemas set org.gnome.shell.extensions.bingwallpaper delete-previous true

gsettings --schemadir $HOME/.local/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/schemas set org.gnome.shell.extensions.bingwallpaper previous-days 14

I will tell you in case I found any issues :)

Any reason why you don't recommend going lower than eight when setting the number of days to delete images? If I set previous-days 1 it apparently works too.

neffo commented 2 months ago

Any reason why you don't recommend going lower than eight when setting the number of days to delete images? If I set previous-days 1 it apparently works too.

In version-49 it'll redownload files that were previously deleted, then delete them again. You will probably notice GNOME hitches when this happens (though this should only happen once per day or on startup). This should be fixed in version-50 which I am aiming to release in the next few days.

neffo commented 1 month ago

Ok, this seems to be working reliably in version 50 now (version 49 this was probably broken).

Screencast From 2024-09-27 18-46-11.webm

neffo commented 1 month ago

Let me know how you find this, or if you encounter any bugs with the new version.

loxoron218 commented 1 month ago

I've been using the new version for a couple of days and it works really good! :)

Since I'm on vacation, I've experienced though that my screen turns blue when the program updates while being offline and using this setting: gsettings --schemadir $HOME/.local/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/schemas set org.gnome.shell.extensions.bingwallpaper previous-days 1

I suppose that it deletes the photo before downloading the next one, being then unable to set any wallpaper. Would it be possible for the program to check for the internet connection before deleting old wallpapers? Perhaps there is another way to solve this? When using previous-days 2 it works perfectly.

Thanks for working on my issue and upgrading to the new Gnome version!