Bugfixes, Readme

This commit is contained in:
2024-01-16 18:14:13 +01:00
parent 3636e3ffac
commit af63b5ad43
6 changed files with 55 additions and 57 deletions

View File

@@ -7,6 +7,7 @@
- Option to display image on lock screens - Option to display image on lock screens
- Bugfixes - Bugfixes
- Remove support for Cinnamon 5.2 and older - Remove support for Cinnamon 5.2 and older
- Apply and OK button to test settings without closing the window
# Version 1.4 # Version 1.4
- Log System - Log System

View File

@@ -29,12 +29,16 @@ This extension switches the background image of your Cinnamon desktop multiple t
- 5.2 (Mint 20.3) - 5.2 (Mint 20.3)
### Technology ### Technology
- Using `JavaScript` for - `JavaScript`
- Location estimation - Display desktop notifications
- Change of the desktop wallpapers - Calling the Python loop script every 60 seconds to refresh the background image
- `Python` displays the preference window - `Python`
- Image Configurator UI was written with `Glade` - Handles the preference window
- Esimates the location
- Changes of the desktop wallpapers
- `Glade`
- Preference window UI design
---
## Installation ## Installation
### From Built-in Extension Manager ### From Built-in Extension Manager
![](res/download-manager.png) ![](res/download-manager.png)
@@ -47,19 +51,21 @@ This extension switches the background image of your Cinnamon desktop multiple t
1. Download the Repository 1. Download the Repository
2. Extract the files 2. Extract the files
3. Copy the folder `cinnamon-dynamic-wallpaper@TobiZog` to `~/.local/share/cinnamon/extensions/` 3. Copy the folder `cinnamon-dynamic-wallpaper@TobiZog` to `~/.local/share/cinnamon/extensions/`
---
## How to use it ## Usage
1. Active the Extension via Cinnamon Extension Manager 1. Active the Extension via Cinnamon Extension Manager
2. Open the settings 2. Open the settings
3. Keep `Estimate coordinates via network` active or disable it and insert latitude and longitude in the fields 3. Configure it to your
4. Choose a set of images or disable it and select for every daytime an image manually - You can apply the setted settings without closing the window if you click on "Apply"
4. If your config is complete, click on "OK"
## Image Configurator ---
The Cinnamon Dynamic Wallpaper extension offers an integrated image configuration assistant. Here, you can choose an included image set or import a HEIC-file from your system. You have to choose the images for the time periods after the import. ## Preferences Window
Because of the lack of configuration options in the standard Cinnamon configuration system for extensions offers this extension a custom preference window.
All configuration will be handled there. You can choose between included image sets, a HEIC file or a folder source and set the image to ten different daytime periods. Time periods will be estimated via network, custom coordinations or custom time periods. Some behaviour preferences (strech image, fill empty background with gradient color) are also here.
![](res/image_configurator.png) ![](res/image_configurator.png)
---
## Included image sets ## Included image sets
The image sets are from https://github.com/adi1090x/dynamic-wallpaper The image sets are from https://github.com/adi1090x/dynamic-wallpaper

View File

@@ -9,29 +9,25 @@ from gi.repository import Gio
from PIL import Image from PIL import Image
suntimes = Suntimes()
location_thread = Location()
background_settings = Gio.Settings.new("org.cinnamon.desktop.background")
class Loop(): class Loop():
def __init__(self) -> None: def __init__(self) -> None:
self.prefs = Cinnamon_Pref_Handler() self.prefs = Cinnamon_Pref_Handler()
self.suntimes = Suntimes()
self.location = Location()
self.background_settings = Gio.Settings.new("org.cinnamon.desktop.background")
# Position should estimate by network # Position should estimate by network
if self.prefs.period_source == PeriodSourceEnum.NETWORKLOCATION: if self.prefs.period_source == PeriodSourceEnum.NETWORKLOCATION:
location_thread.start() current_location = self.location.run()
location_thread.join()
location = location_thread.result self.suntimes.calc_suntimes(float(current_location["latitude"]), float(current_location["longitude"]))
self.start_times = self.suntimes.day_periods
suntimes.calc_suntimes(float(location["latitude"]), float(location["longitude"]))
self.start_times = suntimes.day_periods
# Position is given by user # Position is given by user
elif self.prefs.period_source == PeriodSourceEnum.CUSTOMLOCATION: elif self.prefs.period_source == PeriodSourceEnum.CUSTOMLOCATION:
suntimes.calc_suntimes(float(self.prefs.latitude_custom), float(self.prefs.longitude_custom)) self.suntimes.calc_suntimes(float(self.prefs.latitude_custom), float(self.prefs.longitude_custom))
self.start_times = suntimes.day_periods self.start_times = self.suntimes.day_periods
# No position, concrete times # No position, concrete times
else: else:
@@ -71,10 +67,10 @@ class Loop():
break break
# Set the background # Set the background
background_settings['picture-uri'] = "file://" + self.current_image_uri self.background_settings['picture-uri'] = "file://" + self.current_image_uri
# Set background stretching # Set background stretching
background_settings['picture-options'] = self.prefs.picture_aspect self.background_settings['picture-options'] = self.prefs.picture_aspect
self.set_background_gradient() self.set_background_gradient()
@@ -94,14 +90,14 @@ class Loop():
bottom_color = pix[width / 2, height - 1] bottom_color = pix[width / 2, height - 1]
# Create the gradient # Create the gradient
background_settings['color-shading-type'] = "vertical" self.background_settings['color-shading-type'] = "vertical"
if self.prefs.dynamic_background_color: if self.prefs.dynamic_background_color:
background_settings['primary-color'] = f"#{top_color[0]:x}{top_color[1]:x}{top_color[2]:x}" self.background_settings['primary-color'] = f"#{top_color[0]:x}{top_color[1]:x}{top_color[2]:x}"
background_settings['secondary-color'] = f"#{bottom_color[0]:x}{bottom_color[1]:x}{bottom_color[2]:x}" self.background_settings['secondary-color'] = f"#{bottom_color[0]:x}{bottom_color[1]:x}{bottom_color[2]:x}"
else: else:
background_settings['primary-color'] = "#000000" self.background_settings['primary-color'] = "#000000"
background_settings['secondary-color'] = "#000000" self.background_settings['secondary-color'] = "#000000"
# Needed for JavaScript # Needed for JavaScript

View File

@@ -30,15 +30,17 @@ class Preferences:
############################################################ ############################################################
def __init__(self) -> None: def __init__(self) -> None:
self.builder = Gtk.Builder()
self.builder.add_from_file(GLADE_URI)
self.builder.connect_signals(self)
# Objects from external scripts # Objects from external scripts
self.time_bar_chart = Time_Bar_Chart() self.time_bar_chart = Time_Bar_Chart()
self.c_prefs = Cinnamon_Pref_Handler() self.c_prefs = Cinnamon_Pref_Handler()
self.suntimes = Suntimes() self.suntimes = Suntimes()
self.images = Images() self.images = Images()
self.location = Location()
# Glade
self.builder = Gtk.Builder()
self.builder.add_from_file(GLADE_URI)
self.builder.connect_signals(self)
########## UI objects ########## ########## UI objects ##########
@@ -97,9 +99,9 @@ class Preferences:
self.lbr_custom_location_longitude: Gtk.ListBoxRow = self.builder.get_object("lbr_custom_location_longitude") self.lbr_custom_location_longitude: Gtk.ListBoxRow = self.builder.get_object("lbr_custom_location_longitude")
self.lbr_custom_location_latitude: Gtk.ListBoxRow = self.builder.get_object("lbr_custom_location_latitude") self.lbr_custom_location_latitude: Gtk.ListBoxRow = self.builder.get_object("lbr_custom_location_latitude")
self.lbr_time_periods: Gtk.ListBoxRow = self.builder.get_object("lbr_time_periods") self.lbr_time_periods: Gtk.ListBoxRow = self.builder.get_object("lbr_time_periods")
self.etr_longitude = self.builder.get_object("etr_longitude") self.etr_longitude: Gtk.Entry = self.builder.get_object("etr_longitude")
self.etr_latitude = self.builder.get_object("etr_latitude") self.etr_latitude: Gtk.Entry = self.builder.get_object("etr_latitude")
self.img_bar_times = self.builder.get_object("img_bar_times") self.img_bar_times: Gtk.Image = self.builder.get_object("img_bar_times")
self.spb_periods_hour: list[Gtk.SpinButton] = [ self.spb_periods_hour: list[Gtk.SpinButton] = [
self.builder.get_object("spb_period_1_hour"), self.builder.get_object("spb_period_1_hour"),
self.builder.get_object("spb_period_2_hour"), self.builder.get_object("spb_period_2_hour"),
@@ -477,20 +479,14 @@ class Preferences:
self.spb_network_location_refresh_time.set_value(self.c_prefs.location_refresh_intervals) self.spb_network_location_refresh_time.set_value(self.c_prefs.location_refresh_intervals)
# Start a thread to get the current location
locationThread = Location()
locationThread.start()
locationThread.join()
location = locationThread.result
# Display the location in the UI # Display the location in the UI
self.lb_current_location.set_text("Latitude: " + location["latitude"] + \ current_location = self.location.run()
", Longitude: " + location["longitude"]) self.lb_current_location.set_text("Latitude: " + current_location["latitude"] + \
", Longitude: " + current_location["longitude"])
# Store the location to the preferences # Store the location to the preferences
self.c_prefs.latitude_auto = float(location["latitude"]) self.c_prefs.latitude_auto = float(current_location["latitude"])
self.c_prefs.longitude_auto = float(location["longitude"]) self.c_prefs.longitude_auto = float(current_location["longitude"])
self.refresh_chart() self.refresh_chart()

View File

@@ -1,9 +1,7 @@
import urllib.request, json import urllib.request, json
from threading import Thread
class Location(Thread): class Location():
def __init__(self): def __init__(self):
Thread.__init__(self)
self.GEO_URL = "https://get.geojs.io/v1/ip/geo.json" self.GEO_URL = "https://get.geojs.io/v1/ip/geo.json"
def run(self) -> dict: def run(self) -> dict:
@@ -11,7 +9,7 @@ class Location(Thread):
data = json.load(request) data = json.load(request)
self.result = { return {
"latitude": data["latitude"], "latitude": data["latitude"],
"longitude": data["longitude"] "longitude": data["longitude"]
} }

View File

@@ -8,7 +8,8 @@
"cinnamon-version": [ "cinnamon-version": [
"5.4", "5.4",
"5.6", "5.6",
"5.8" "5.8",
"6.0"
], ],
"max-instances": 1, "max-instances": 1,
"url": "https://github.com/TobiZog/cinnamon-dynamic-wallpaper" "url": "https://github.com/TobiZog/cinnamon-dynamic-wallpaper"