From 5f52ae959a5c98aa2ed9ecfc3ed397fb4917174e Mon Sep 17 00:00:00 2001 From: TobiZog Date: Thu, 13 Jul 2023 18:46:40 +0200 Subject: [PATCH] Readme, bugfix, documentation --- README.md | 3 + .../4.8/icon.png | 2 +- .../5.4/extension.js | 53 +++++++++++------- .../5.4/icon.png | 2 +- .../5.4/{icon => icons}/icon.png | Bin cinnamon-dynamic-wallpaper@TobiZog/icon.png | 1 + .../metadata.json | 2 +- 7 files changed, 39 insertions(+), 24 deletions(-) rename cinnamon-dynamic-wallpaper@TobiZog/5.4/{icon => icons}/icon.png (100%) create mode 120000 cinnamon-dynamic-wallpaper@TobiZog/icon.png diff --git a/README.md b/README.md index 907a2b1..deb714f 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ Based on a location, this extension calculates the periods of a day and switches - Offline sun angles estimation ### Tested Cinnamon versions +- 4.8 (Mint 20.1) +- 5.0 (Mint 20.2) +- 5.2 (Mint 20.3) - 5.4 (Mint 21) - 5.6 (Mint 21.1) - 5.8 (Mint 21.2) diff --git a/cinnamon-dynamic-wallpaper@TobiZog/4.8/icon.png b/cinnamon-dynamic-wallpaper@TobiZog/4.8/icon.png index 169ca12..1da76b6 120000 --- a/cinnamon-dynamic-wallpaper@TobiZog/4.8/icon.png +++ b/cinnamon-dynamic-wallpaper@TobiZog/4.8/icon.png @@ -1 +1 @@ -../5.4/icon/icon.png \ No newline at end of file +../5.4/icons/icon.png \ No newline at end of file diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/extension.js b/cinnamon-dynamic-wallpaper@TobiZog/5.4/extension.js index d704449..853b98e 100644 --- a/cinnamon-dynamic-wallpaper@TobiZog/5.4/extension.js +++ b/cinnamon-dynamic-wallpaper@TobiZog/5.4/extension.js @@ -72,30 +72,43 @@ CinnamonDynamicWallpaperExtension.prototype = { this.bindSettings("etr_img_night_twilight", "img_night_twilight", this.setImageToTime) this.bindSettings("etr_img_night", "img_night", this.setImageToTime) this.bindSettings("tv_times", "tvTimes") - - this.setImageToTime() - - this._loop() - // Check for the first startup if (this.settings.getValue("first_start")) { - this.showNotification("Welcome to Cinnamon Dynamic Wallpaper", "Check the preferences to choose a dynamic wallpaper", true) + // Welcome notification + this.showNotification("Welcome to Cinnamon Dynamic Wallpaper", + "Check the preferences to choose a dynamic wallpaper", true) + + // Hide the notification on system restart this.settings.setValue("first_start", false) - // Copy the default wallpaper to the folder + // Create the folder for the selected images Util.spawnCommandLine("mkdir " + DIRECTORY.path + "/images/selected/") - global.log("mkdir " + DIRECTORY.path + "/images/selected") + // Link the default wallpaper to the folder for (let i = 1; i <= 9; i++) { Util.spawnCommandLine("ln -s " + DIRECTORY.path + "/images/included_image_sets/lakeside/" + i + ".jpg " + DIRECTORY.path + "/images/selected/" + i + ".jpg"); } } + + + // Set image initial at desktop wallpaper + this.setImageToTime() + + // Start the main loop, checks in fixed time periods the + this._loop() }, + /** + * Binding the settings objects + * + * @param {*} ui_name Name of preference in settings-schema.json + * @param {*} js_name Name of preference in JavaScript + * @param {*} func Function to call on change + */ bindSettings: function (ui_name, js_name, func = this.on_settings_changed) { this.settings.bindProperty( Settings.BindingDirection.IN, @@ -105,13 +118,13 @@ CinnamonDynamicWallpaperExtension.prototype = { ) }, - /** * Displaying a desktop notification * * @param {string} title The Title in the notification * @param {string} text The text in the notification - * @param {boolean} showOpenSettings Display the "Open settings" button in the notification, defaults to false + * @param {boolean} showOpenSettings Display the "Open settings" button in the notification, + * defaults to false */ showNotification: function (title, text, showOpenSettings = false) { let source = new MessageTray.Source(this.uuid); @@ -157,7 +170,9 @@ CinnamonDynamicWallpaperExtension.prototype = { }, - + /** + * Estimate the right image based on time period of the day + */ setImageToTime: function() { let times = suntimes.calcTimePeriod(this.latitude, this.longitude) let now = new Date() @@ -176,7 +191,6 @@ CinnamonDynamicWallpaperExtension.prototype = { for(let i = 0; i < timesArray.length; i++) { if(timesArray[i][0] <= now && now <= timesArray[i][1] && i != lastDayTime) { - global.log(PATH + "/res/images/selected/" + imageSet[i]) this.changeWallpaper("file://" + PATH + "/images/selected/" + imageSet[i]) lastDayTime = i @@ -201,7 +215,10 @@ CinnamonDynamicWallpaperExtension.prototype = { "\nNight:\t\t\t\t" + convertToTimeString(timesArray[8][0]) + " - " + convertToTimeString(timesArray[8][1]) }, - + /** + * Get the location of the user + * Callback for changes in preferences + */ updateLocation: function () { if (this.autolocation) { let loc = location.estimateLocation() @@ -227,7 +244,8 @@ CinnamonDynamicWallpaperExtension.prototype = { * Opens the external heic-importer window */ openImageConfigurator: function() { - Util.spawnCommandLine("/usr/bin/env python3 " + DIRECTORY.path + "/image-configurator/image-configurator.py"); + Util.spawnCommandLine("/usr/bin/env python3 " + + DIRECTORY.path + "/image-configurator/image-configurator.py"); }, @@ -283,13 +301,6 @@ function enable() { Util.spawnCommandLine("apturl apt://libheif-examples"); } - // Display the welcome notification on activation - // extension.showNotification( - // APPNAME, - // "Welcome to " + APPNAME + "! Open the settings and configure the extensions.", - // true - // ); - return extension; } diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/icon.png b/cinnamon-dynamic-wallpaper@TobiZog/5.4/icon.png index 01d1af9..9db683c 120000 --- a/cinnamon-dynamic-wallpaper@TobiZog/5.4/icon.png +++ b/cinnamon-dynamic-wallpaper@TobiZog/5.4/icon.png @@ -1 +1 @@ -icon/icon.png \ No newline at end of file +icons/icon.png \ No newline at end of file diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/icon/icon.png b/cinnamon-dynamic-wallpaper@TobiZog/5.4/icons/icon.png similarity index 100% rename from cinnamon-dynamic-wallpaper@TobiZog/5.4/icon/icon.png rename to cinnamon-dynamic-wallpaper@TobiZog/5.4/icons/icon.png diff --git a/cinnamon-dynamic-wallpaper@TobiZog/icon.png b/cinnamon-dynamic-wallpaper@TobiZog/icon.png new file mode 120000 index 0000000..3c8c923 --- /dev/null +++ b/cinnamon-dynamic-wallpaper@TobiZog/icon.png @@ -0,0 +1 @@ +5.4/icons/icon.png \ No newline at end of file diff --git a/cinnamon-dynamic-wallpaper@TobiZog/metadata.json b/cinnamon-dynamic-wallpaper@TobiZog/metadata.json index b8ea4b4..07b5fc6 100644 --- a/cinnamon-dynamic-wallpaper@TobiZog/metadata.json +++ b/cinnamon-dynamic-wallpaper@TobiZog/metadata.json @@ -2,7 +2,7 @@ "uuid": "cinnamon-dynamic-wallpaper@TobiZog", "name": "Cinnamon Dynamic Wallpaper", "description": "Cinnamon extension for dynamic desktop backgrounds based on time and location", - "version": "1.1", + "version": "1.2", "multiversion": true, "cinnamon-version": [ "4.8",