diff --git a/cinnamon-dynamic-wallpaper@TobiZog/CHANGELOG b/cinnamon-dynamic-wallpaper@TobiZog/CHANGELOG index 2218fa40..01b2236a 100644 --- a/cinnamon-dynamic-wallpaper@TobiZog/CHANGELOG +++ b/cinnamon-dynamic-wallpaper@TobiZog/CHANGELOG @@ -1,3 +1,9 @@ +# Version 1.4 +- Log System +- Bugfixes +- Display times in Image Configurator +- Display time of last location update in Preferences + # Version 1.3 - Adding option to stretch the image over multiple displays diff --git a/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/extension.js b/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/extension.js index 9ab27e32..66cac84c 100644 --- a/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/extension.js +++ b/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/extension.js @@ -1,14 +1,13 @@ /** * @name Cinnamon-Dynamic-Wallpaper * @alias TobiZog - * @since 2023 + * @since 2023-05-17 + * + * @description Main application file */ /******************** Imports ********************/ -const MessageTray = imports.ui.messageTray; -const St = imports.gi.St; -const Main = imports.ui.main; const Util = imports.misc.util; const Settings = imports.ui.settings; const Mainloop = imports.mainloop; @@ -18,6 +17,7 @@ const Gio = imports.gi.Gio; let suntimes = require('./scripts/suntimes') let location = require('./scripts/location') +let communication = require('./scripts/communication') /******************** Constants ********************/ @@ -34,11 +34,12 @@ const PATH = DIRECTORY.path; let extension; // Time and date of the last location update -let lastLocationUpdate = new Date() +let lastLocationUpdate = -1 // The last calculated suntime of the day let lastDayTime = suntimes.DAYPERIOD.NONE +// Loop state let looping = true @@ -50,26 +51,37 @@ function CinnamonDynamicWallpaperExtension(uuid) { CinnamonDynamicWallpaperExtension.prototype = { + + /******************** Lifecycle ********************/ + /** * Initialization * * @param {string} uuid Universally Unique Identifier */ - _init: function (uuid) { + _init: function(uuid) { this.settings = new Settings.ExtensionSettings(this, uuid); + /** Configuration */ // Image set this.bindSettings("sw_image_stretch", "imageStretch", this.settingsUpdated) // Location estimation this.bindSettings("sw_auto_location", "autolocation", this.settingsUpdated) this.bindSettings("sc_location_refresh_time", "locationRefreshTime", this.settingsUpdated) + this.bindSettings("etr_last_update", "etrLastUpdate") this.bindSettings("etr_latitude", "latitude", this.settingsUpdated) this.bindSettings("etr_longitude", "longitude", this.settingsUpdated) // Time periods this.bindSettings("tv_times", "tvTimes") + + /** Debugging */ + // Logs + this.bindSettings("tv_logs", "tvLogs") + + // Image Configurator this.bindSettings("etr_img_morning_twilight", "img_morning_twilight", this.settingsUpdated) this.bindSettings("etr_img_sunrise", "img_sunrise", this.settingsUpdated) @@ -81,11 +93,23 @@ CinnamonDynamicWallpaperExtension.prototype = { this.bindSettings("etr_img_night_twilight", "img_night_twilight", this.settingsUpdated) this.bindSettings("etr_img_night", "img_night", this.settingsUpdated) + this.bindSettings("etr_morning_twilight_times", "img_morning_twilight_times") + this.bindSettings("etr_sunrise_times", "img_sunrise_times") + this.bindSettings("etr_morning_times", "img_morning_times") + this.bindSettings("etr_noon_times", "img_noon_times") + this.bindSettings("etr_afternoon_times", "img_afternoon_times") + this.bindSettings("etr_evening_times", "img_evening_times") + this.bindSettings("etr_sunset_times", "img_sunset_times") + this.bindSettings("etr_night_twilight_times", "img_night_twilight_times") + this.bindSettings("etr_night_times", "img_night_times") + // Check for the first startup if (this.settings.getValue("first_start")) { + this.writeToLogs("First time start") + // Welcome notification - this.showNotification("Welcome to Cinnamon Dynamic Wallpaper", + communication.showNotification("Welcome to Cinnamon Dynamic Wallpaper", "Check the preferences to choose a dynamic wallpaper", true) // Hide the notification on system restart @@ -96,12 +120,13 @@ CinnamonDynamicWallpaperExtension.prototype = { // 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"); + Util.spawnCommandLine("ln -s " + + DIRECTORY.path + "/images/included_image_sets/lakeside/" + i + ".jpg " + + DIRECTORY.path + "/images/selected/" + i + ".jpg"); } } + this.writeToLogs("Initialization completed") // Set image initial at desktop wallpaper this.setImageToTime() @@ -114,9 +139,9 @@ CinnamonDynamicWallpaperExtension.prototype = { /** * 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 + * @param {string} ui_name Name of preference in settings-schema.json + * @param {string} js_name Name of preference in JavaScript + * @param {Function} func Function to call on change */ bindSettings: function (ui_name, js_name, func = this.on_settings_changed) { this.settings.bindProperty( @@ -128,87 +153,114 @@ CinnamonDynamicWallpaperExtension.prototype = { }, + /** + * Main loop + */ + _loop: function () { + if (looping) { + this.setImageToTime() + + // Update the location, if the user choose "autoLocation" and the timer has expired + if ((lastLocationUpdate == -1 || + lastLocationUpdate.getTime() < new Date().getTime() - this.locationRefreshTime * 60000) && + this.autolocation) + { + this.updateLocation() + lastLocationUpdate = new Date() + } + + // Refresh every 60 seconds + Mainloop.timeout_add_seconds(60, Lang.bind(this, this._loop)); + this.writeToLogs("Main loop runs...") + } + }, + + + /******************** Settings handling ********************/ + /** * Handles changes in settings */ - settingsUpdated: function () { + settingsUpdated: function() { lastDayTime = suntimes.DAYPERIOD.NONE this.updateLocation() this.setImageToTime() }, + /** + * Callback for settings-schema + * Opens the external image configurator window + */ + openImageConfigurator: function () { + Util.spawnCommandLine("/usr/bin/env python3 " + + DIRECTORY.path + "/image-configurator/image-configurator.py"); + }, + /** - * 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 + * Callback for settings-schema + * Opens the browser and navigates to the URL of the respository */ - showNotification: function (title, text, showOpenSettings = false) { - let source = new MessageTray.Source(this.uuid); - - // Parameter - let params = { - icon: new St.Icon({ - icon_name: "icon", - icon_type: St.IconType.FULLCOLOR, - icon_size: source.ICON_SIZE - }) - }; - - // The notification itself - let notification = new MessageTray.Notification(source, title, text, params); - - // Display the "Open settings" button, if showOpenSettings - if (showOpenSettings) { - notification.addButton("open-settings", _("Open settings")); - - notification.connect("action-invoked", () => - Util.spawnCommandLine("xlet-settings extension " + UUID)); - } + openRepoWebsite: function () { + Util.spawnCommandLine("xdg-open https://github.com/TobiZog/cinnamon-dynamic-wallpaper"); + }, + + + /** + * Callback for settings-schema + * Opens the browser and navigates to the URL of the Cinnamon Spices extension + */ + openSpicesWebsite: function () { + Util.spawnCommandLine("xdg-open https://cinnamon-spices.linuxmint.com/extensions/view/97") + }, - // Put all together - Main.messageTray.add(source); - // Display it - source.notify(notification); + /** + * Callback for settings-schema + * Opens the browser and navigates to the GitHub issue page + */ + openIssueWebsite: function () { + Util.spawnCommandLine("xdg-open https://github.com/TobiZog/cinnamon-dynamic-wallpaper/issues/new") }, + /******************** Other functions ********************/ + /** * Changes the desktop background image * * @param {jpg} imageURI The new desktop image */ - changeWallpaper: function (imageURI) { - let gSetting = new Gio.Settings({ schema: 'org.cinnamon.desktop.background' }); + changeWallpaper: function(imageURI) { + let gSetting = new Gio.Settings({schema: 'org.cinnamon.desktop.background'}); gSetting.set_string('picture-uri', imageURI); if (this.imageStretch) { gSetting.set_string('picture-options', 'spanned') } - else { + else + { gSetting.set_string('picture-options', 'zoom') } Gio.Settings.sync(); gSetting.apply(); + + this.writeToLogs("Set new image: " + imageURI) }, /** * Estimate the right image based on time period of the day */ - setImageToTime: function () { + setImageToTime: function() { let times = suntimes.calcTimePeriod(this.latitude, this.longitude) let now = new Date() let timesArray = [ times["morning_twilight"], times["sunrise"], times["morning"], - times["noon"], times["afternoon"], times["evening"], + times["noon"], times["afternoon"], times["evening"], times["sunset"], times["night_twilight"], times["night"] ] @@ -218,21 +270,31 @@ CinnamonDynamicWallpaperExtension.prototype = { this.img_sunset, this.img_night_twilight, this.img_night ] - for (let i = 0; i < timesArray.length; i++) { - if (timesArray[i][0] <= now && now <= timesArray[i][1] && i != lastDayTime) { + for(let i = 0; i < timesArray.length; i++) { + if(timesArray[i][0] <= now && now <= timesArray[i][1] && i != lastDayTime) { this.changeWallpaper("file://" + PATH + "/images/selected/" + imageSet[i]) lastDayTime = i break } } - - + function convertToTimeString(time) { return time.getHours().toString().padStart(2, "0") + ":" + time.getMinutes().toString().padStart(2, "0") } - this.tvTimes = + + this.img_morning_twilight_times = convertToTimeString(timesArray[0][0]) + " - " + convertToTimeString(timesArray[0][1]) + this.img_sunrise_times = convertToTimeString(timesArray[1][0]) + " - " + convertToTimeString(timesArray[1][1]) + this.img_morning_times = convertToTimeString(timesArray[2][0]) + " - " + convertToTimeString(timesArray[2][1]) + this.img_noon_times = convertToTimeString(timesArray[3][0]) + " - " + convertToTimeString(timesArray[3][1]) + this.img_afternoon_times = convertToTimeString(timesArray[4][0]) + " - " + convertToTimeString(timesArray[4][1]) + this.img_evening_times = convertToTimeString(timesArray[5][0]) + " - " + convertToTimeString(timesArray[5][1]) + this.img_sunset_times = convertToTimeString(timesArray[6][0]) + " - " + convertToTimeString(timesArray[6][1]) + this.img_night_twilight_times = convertToTimeString(timesArray[7][0]) + " - " + convertToTimeString(timesArray[7][1]) + this.img_night_times = convertToTimeString(timesArray[8][0]) + " - " + convertToTimeString(timesArray[8][1]) + + this.tvTimes = "Morning Twilight:\t\t" + convertToTimeString(timesArray[0][0]) + " - " + convertToTimeString(timesArray[0][1]) + "\nSunrise:\t\t\t\t" + convertToTimeString(timesArray[1][0]) + " - " + convertToTimeString(timesArray[1][1]) + "\nMorning:\t\t\t" + convertToTimeString(timesArray[2][0]) + " - " + convertToTimeString(timesArray[2][1]) + @@ -249,74 +311,27 @@ CinnamonDynamicWallpaperExtension.prototype = { * Callback for changes in preferences */ updateLocation: function () { + // Update the update information + lastLocationUpdate = new Date() + if (this.autolocation) { let loc = location.estimateLocation() this.latitude = loc["latitude"] this.longitude = loc["longitude"] - } else { - this.latitude = this.latitude - this.longitude = this.longitude - } - - // Update the update information - lastLocationUpdate = new Date() - }, - - - /** - * Main loop - */ - _loop: function () { - if (looping) { - this.setImageToTime() - - if (lastLocationUpdate < new Date().getTime() - this.locationRefreshTime * 1000) { - this.updateLocation() - lastLocationUpdate = new Date() - } - // Refresh every 60 seconds - Mainloop.timeout_add_seconds(60, Lang.bind(this, this._loop)); + this.etrLastUpdate = lastLocationUpdate.getHours() + ":" + lastLocationUpdate.getMinutes() } - }, - - - /******************** UI Callbacks ********************/ - /** - * Callback for settings-schema - * Opens the external image configurator window - */ - openImageConfigurator: function () { - Util.spawnCommandLine("/usr/bin/env python3 " + - DIRECTORY.path + "/image-configurator/image-configurator.py"); + this.writeToLogs("Location updated") }, - /** - * Callback for settings-schema - * Opens the browser and navigates to the URL of the respository - */ - openRepoWebsite: function () { - Util.spawnCommandLine("xdg-open https://github.com/TobiZog/cinnamon-dynamic-wallpaper"); - }, - - - /** - * Callback for settings-schema - * Opens the browser and navigates to the URL of the Cinnamon Spices extension - */ - openSpicesWebsite: function () { - Util.spawnCommandLine("xdg-open https://cinnamon-spices.linuxmint.com/extensions/view/97") - }, - - - /** - * Callback for settings-schema - * Opens the browser and navigates to the GitHub issue page + * Adding text to the logs + * + * @param {string} msg New message string */ - openIssueWebsite: function () { - Util.spawnCommandLine("xdg-open https://github.com/TobiZog/cinnamon-dynamic-wallpaper/issues/new") + writeToLogs: function(msg) { + this.tvLogs = communication.createLogs(this.tvLogs, msg) } } @@ -354,4 +369,4 @@ function enable() { */ function disable() { looping = false -} \ No newline at end of file +} diff --git a/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/image-configurator/image-configurator.glade b/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/image-configurator/image-configurator.glade index 35d9abb8..a28b860e 100644 --- a/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/image-configurator/image-configurator.glade +++ b/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/image-configurator/image-configurator.glade @@ -250,6 +250,18 @@ False vertical 8 + + + True + False + label + + + False + True + 0 + + 300 @@ -263,7 +275,7 @@ False True - 0 + 1 @@ -275,7 +287,7 @@ False True - 1 + 2 @@ -317,6 +329,18 @@ False vertical 8 + + + True + False + label + + + False + True + 0 + + 300 @@ -329,7 +353,7 @@ False True - 0 + 1 @@ -340,7 +364,7 @@ False True - 1 + 2 @@ -382,6 +406,18 @@ False vertical 8 + + + True + False + label + + + False + True + 0 + + 300 @@ -394,7 +430,7 @@ False True - 0 + 1 @@ -406,7 +442,7 @@ False True - 1 + 2 @@ -448,6 +484,18 @@ False vertical 8 + + + True + False + label + + + False + True + 0 + + 300 @@ -460,7 +508,7 @@ False True - 0 + 1 @@ -471,7 +519,7 @@ False True - 1 + 2 @@ -513,6 +561,18 @@ False vertical 8 + + + True + False + label + + + False + True + 0 + + 300 @@ -525,7 +585,7 @@ False True - 0 + 1 @@ -537,7 +597,7 @@ False True - 1 + 2 @@ -579,6 +639,18 @@ False vertical 8 + + + True + False + label + + + False + True + 0 + + 300 @@ -591,7 +663,7 @@ False True - 0 + 1 @@ -603,7 +675,7 @@ False True - 1 + 2 @@ -645,6 +717,18 @@ False vertical 8 + + + True + False + label + + + False + True + 0 + + 300 @@ -657,7 +741,7 @@ False True - 0 + 1 @@ -669,7 +753,7 @@ False True - 1 + 2 @@ -711,6 +795,18 @@ False vertical 8 + + + True + False + label + + + False + True + 0 + + 300 @@ -723,7 +819,7 @@ False True - 0 + 1 @@ -735,7 +831,7 @@ False True - 1 + 2 @@ -777,6 +873,18 @@ False vertical 8 + + + True + False + label + + + False + True + 0 + + 300 @@ -789,7 +897,7 @@ False True - 0 + 1 @@ -801,7 +909,7 @@ False True - 1 + 2 diff --git a/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/image-configurator/windowHandler.py b/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/image-configurator/windowHandler.py index 4668d0da..165265b2 100644 --- a/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/image-configurator/windowHandler.py +++ b/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/image-configurator/windowHandler.py @@ -12,6 +12,7 @@ IMAGE_EXTRACT_DIR = IMAGE_DIR + "extracted/" IMAGE_SETS_DIR = IMAGE_DIR + "included_image_sets/" IMAGE_SELECTED_DIR = IMAGE_DIR + "selected/" +IMAGE_DEFAULT_DIR = IMAGE_DIR + "default/" class WindowHandler: @@ -20,7 +21,19 @@ def __init__(self, pref_path: str) -> None: ########### Class variables ########### self.pref_path = pref_path - self.pref_vars = [ + self.time_values = [ + "etr_morning_twilight_times", + "etr_sunrise_times", + "etr_morning_times", + "etr_noon_times", + "etr_afternoon_times", + "etr_evening_times", + "etr_sunset_times", + "etr_night_twilight_times", + "etr_night_times" + ] + + self.img_values = [ "etr_img_morning_twilight", "etr_img_sunrise", "etr_img_morning", @@ -69,6 +82,18 @@ def __init__(self, pref_path: str) -> None: self.lb_heic_file = self.builder.get_object("lb_heic_file") self.fc_heic_file = self.builder.get_object("fc_heic_file") + self.lb_times = [ + self.builder.get_object("lb_times_1"), + self.builder.get_object("lb_times_2"), + self.builder.get_object("lb_times_3"), + self.builder.get_object("lb_times_4"), + self.builder.get_object("lb_times_5"), + self.builder.get_object("lb_times_6"), + self.builder.get_object("lb_times_7"), + self.builder.get_object("lb_times_8"), + self.builder.get_object("lb_times_9") + ] + self.img_previews = [ self.builder.get_object("img_preview_1"), self.builder.get_object("img_preview_2"), @@ -147,21 +172,25 @@ def loadFromSettings(self): self.cb_image_set.set_active(i) - for i, val in enumerate(self.pref_vars): - # Set the preview image - self.changePreviewImage(i, IMAGE_SELECTED_DIR + pref_data[val]['value']) + for i, val in enumerate(self.img_values): + # Bugfix: Load the images only, if there is choosen one + if pref_data[val]['value'] != None: + # Set the preview image + self.changePreviewImage(i, IMAGE_SELECTED_DIR + pref_data[val]['value']) + + # Set the ComboBox selection + if pref_data["etr_choosen_image_set"]["value"] == "custom": + self.image_source = Source.EXTRACT - # Set the ComboBox selection - if pref_data["etr_choosen_image_set"]["value"] == "custom": - self.image_source = Source.EXTRACT + for j, set in enumerate(choosable_images): + if set == pref_data[val]["value"]: + self.cb_previews[i].set_active(j) + else: + self.image_source = Source.SET - for j, set in enumerate(choosable_images): - if set == pref_data[val]["value"]: - self.cb_previews[i].set_active(j) - else: - self.image_source = Source.SET - #except: - # pass + # Print the times of the day + for i, val in enumerate(self.time_values): + self.lb_times[i].set_text(pref_data[val]['value']) def writeToSettings(self): @@ -176,13 +205,15 @@ def writeToSettings(self): if self.image_source == Source.SET: pref_data["etr_choosen_image_set"]["value"] = self.cb_image_set.get_active_text() - for i, val in enumerate(self.pref_vars): + for i, val in enumerate(self.img_values): pref_data[val]['value'] = str(i + 1) + ".jpg" else: pref_data["etr_choosen_image_set"]["value"] = "custom" - for i, val in enumerate(self.pref_vars): - pref_data[val]['value'] = self.cb_previews[i].get_active_text() + for i, val in enumerate(self.img_values): + image_name = self.cb_previews[i].get_active_text() + + pref_data[val]['value'] = image_name # Write the settings @@ -219,7 +250,7 @@ def extractHeifImages(self, imageURI: str): self.image_source = Source.EXTRACT self.wipeImages(Source.EXTRACT) - os.system("heif-convert " + imageURI + " " + IMAGE_EXTRACT_DIR + "/" + filename + ".jpg") + os.system("heif-convert " + imageURI + " " + IMAGE_EXTRACT_DIR + filename + ".jpg") self.createExtracted() diff --git a/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/scripts/communication.js b/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/scripts/communication.js new file mode 100644 index 00000000..5fb644ad --- /dev/null +++ b/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/scripts/communication.js @@ -0,0 +1,84 @@ +/** + * @name Cinnamon-Dynamic-Wallpaper + * @alias TobiZog + * @since 2023-08-25 + * + * @description Handles communications with the user (notifications, logs) + */ + +/******************** Imports ********************/ + +const St = imports.gi.St; +const Main = imports.ui.main; +const Util = imports.misc.util; +const MessageTray = imports.ui.messageTray; + + + + +/******************** Functions ********************/ + +/** + * 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 + */ +function showNotification(title, text, showOpenSettings = false) { + let source = new MessageTray.Source(this.uuid); + + // Parameter + let params = { + icon: new St.Icon({ + icon_name: "icon", + icon_type: St.IconType.FULLCOLOR, + icon_size: source.ICON_SIZE + }) + }; + // The notification itself + let notification = new MessageTray.Notification(source, title, text, params); + + // Display the "Open settings" button, if showOpenSettings + if (showOpenSettings) { + notification.addButton("open-settings", _("Open settings")); + + notification.connect("action-invoked", () => + Util.spawnCommandLine("xlet-settings extension " + UUID)); + } + + // Put all together + Main.messageTray.add(source); + + // Display it + source.notify(notification); +} + + +/** + * Adding a message to the logs + * + * @param {string} logMsg New log message to add + */ +function createLogs(tvLogs, logMsg) { + /** + * Pad a number with leading zeros + * + * @param {number} num Number to format + * @param {number} size Final string length + * + * @returns String with defined length + */ + function pad(num, size) { + var s = "00" + num + return s.substring(s.length - size) + } + + // Estimate date and time + let date = new Date() + let formattedDate = pad(date.getHours(), 2) + ":" + pad(date.getMinutes(), 2) + ":" + pad(date.getSeconds(), 2) + + // Add the the logs + return formattedDate + "\t" + logMsg + "\n" + tvLogs +} \ No newline at end of file diff --git a/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/scripts/location.js b/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/scripts/location.js index 0b632859..bd9f1ffb 100644 --- a/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/scripts/location.js +++ b/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/scripts/location.js @@ -1,6 +1,23 @@ +/** + * @name Cinnamon-Dynamic-Wallpaper + * @alias TobiZog + * @since 2023 + * + * @description Functions to estimate the user location + */ + +/******************** Imports ********************/ + const Soup = imports.gi.Soup; +/******************** Functions ********************/ + +/** + * Estimate the location of the user + * + * @returns Location data if succeded or -1 if failed + */ function estimateLocation() { let sessionSync = new Soup.SessionSync(); let msg = Soup.Message.new('GET', "https://get.geojs.io/v1/ip/geo.json"); diff --git a/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/scripts/suntimes.js b/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/scripts/suntimes.js index ab664f9c..7138199b 100644 --- a/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/scripts/suntimes.js +++ b/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/scripts/suntimes.js @@ -2,8 +2,12 @@ * @name Cinnamon-Dynamic-Wallpaper * @alias TobiZog * @since 2023 + * + * @description Functions to calculate sun time periods */ +/******************** Constants ********************/ + const DAYPERIOD = { MTWILIGHT: 0, SUNRISE: 1, @@ -22,6 +26,9 @@ const J1970 = 2440588 const J2000 = 2451545 +/******************** Functions ********************/ + + function fromJulian(j) { let ms_date = (j + 0.5 - J1970) * DAYMS return new Date(ms_date) @@ -83,6 +90,14 @@ function subTimesToMinutes(date1, date2) { } +/** + * Calculating the start and end time of all time periods of the day + * + * @param {float} latitude Location latitude + * @param {float} longitude Location longitude + * + * @returns JSON of time periods + */ function calcTimePeriod(latitude, longitude) { let todaySunEventsDay = sunEventsOfDay(latitude, longitude, Date.now()) let tomorrowSunEventsDay = sunEventsOfDay(latitude, longitude, addMinutesToTime(new Date(), 1440)) diff --git a/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/settings-schema.json b/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/settings-schema.json index ac698b89..1d16f1e6 100644 --- a/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/settings-schema.json +++ b/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/5.4/settings-schema.json @@ -3,8 +3,12 @@ "type": "layout", "pages": [ "pg_config", + "pg_logs", "pg_about" ], + + + "pg_config": { "type": "page", "title": "Configuration", @@ -14,17 +18,25 @@ "sec_times" ] }, + "pg_logs": { + "type": "page", + "title": "Debugging", + "sections": [ + "sec_logs", + "sec_report_issue" + ] + }, "pg_about": { "type": "page", "title": "About", "sections": [ "sec_project", - "sec_github", - "sec_report_issue" + "sec_github" ] }, + "sec_image_configuration": { "type": "section", "title": "Image set", @@ -40,10 +52,11 @@ "keys": [ "sw_auto_location", "sc_location_refresh_time", + "etr_last_update", "etr_latitude", "etr_longitude" ] - }, + }, "sec_times": { "type": "section", "title": "Time periods", @@ -51,6 +64,26 @@ "tv_times" ] }, + + + "sec_logs": { + "type": "section", + "title": "Logs", + "keys": [ + "tv_log_description", + "tv_logs" + ] + }, + "sec_report_issue": { + "type": "section", + "title": "Report an issue", + "keys": [ + "lb_report_issue", + "btn_report_issue" + ] + }, + + "sec_project": { "type": "section", "title": "About the project", @@ -68,18 +101,11 @@ "lb_repository", "btn_open_repository" ] - }, - "sec_report_issue": { - "type": "section", - "title": "Report an issue", - "keys": [ - "lb_report_issue", - "btn_report_issue" - ] } }, + "lb_image_configuration": { "type": "label", "description": "Choose an included image set or import a heic-file with the Image Configurator" @@ -92,8 +118,9 @@ "sw_image_stretch": { "type": "switch", "description": "Expand image over all displays", - "default": true + "default": false }, + "sw_auto_location": { "type": "switch", "default": true, @@ -108,6 +135,12 @@ "description": "Interval time to refresh the location via network (min)", "dependency": "sw_auto_location" }, + "etr_last_update": { + "type": "entry", + "description": "Last location update", + "default": "", + "dependency": "sw_auto_location" + }, "etr_latitude": { "type": "entry", "default": "", @@ -120,12 +153,35 @@ "description": "Longitude", "dependency": "!sw_auto_location" }, + "tv_times": { "type": "textview", "description": "Time sections today", "default": "" }, + + "tv_log_description": { + "type": "label", + "description": "Logs contains informations about time, date and successful or failed operations of the extension.", + "default": "" + }, + "tv_logs": { + "type": "textview", + "description": "See all logs", + "default": "" + }, + + "lb_report_issue": { + "type": "label", + "description": "Do you find an issue? Or want a new feature? Go to the GitHub repository and create a new issue. If you find an error message in the logs above, add it to the issue report." + }, + "btn_report_issue": { + "type": "button", + "description": "Submit an Issue", + "callback": "openIssueWebsite" + }, + "lb_about": { "type": "label", @@ -155,16 +211,7 @@ "callback": "openRepoWebsite" }, - "lb_report_issue": { - "type": "label", - "description": "Do you find an issue? Or want a new feature? Go to the GitHub repository and create a new issue." - }, - - "btn_report_issue": { - "type": "button", - "description": "Submit an Issue", - "callback": "openIssueWebsite" - }, + "etr_choosen_image_set": { @@ -220,5 +267,51 @@ "first_start": { "type": "generic", "default": true + }, + + "etr_morning_twilight_times": { + "type": "entry", + "default": "", + "description": "" + }, + "etr_sunrise_times": { + "type": "entry", + "default": "", + "description": "" + }, + "etr_morning_times": { + "type": "entry", + "default": "", + "description": "" + }, + "etr_noon_times": { + "type": "entry", + "default": "", + "description": "" + }, + "etr_afternoon_times": { + "type": "entry", + "default": "", + "description": "" + }, + "etr_evening_times": { + "type": "entry", + "default": "", + "description": "" + }, + "etr_sunset_times": { + "type": "entry", + "default": "", + "description": "" + }, + "etr_night_twilight_times": { + "type": "entry", + "default": "", + "description": "" + }, + "etr_night_times": { + "type": "entry", + "default": "", + "description": "" } } \ No newline at end of file diff --git a/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/metadata.json b/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/metadata.json index 7608d2d6..d547f709 100644 --- a/cinnamon-dynamic-wallpaper@TobiZog/files/cinnamon-dynamic-wallpaper@TobiZog/metadata.json +++ b/cinnamon-dynamic-wallpaper@TobiZog/files/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.3", + "version": "1.4", "multiversion": true, "cinnamon-version": [ "4.8",