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
- Bugfixes
- Remove support for Cinnamon 5.2 and older
- Apply and OK button to test settings without closing the window
# Version 1.4
- 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)
### Technology
- Using `JavaScript` for
- Location estimation
- Change of the desktop wallpapers
- `Python` displays the preference window
- Image Configurator UI was written with `Glade`
- `JavaScript`
- Display desktop notifications
- Calling the Python loop script every 60 seconds to refresh the background image
- `Python`
- Handles the preference window
- Esimates the location
- Changes of the desktop wallpapers
- `Glade`
- Preference window UI design
---
## Installation
### From Built-in Extension Manager
![](res/download-manager.png)
@@ -47,19 +51,21 @@ This extension switches the background image of your Cinnamon desktop multiple t
1. Download the Repository
2. Extract the files
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
2. Open the settings
3. Keep `Estimate coordinates via network` active or disable it and insert latitude and longitude in the fields
4. Choose a set of images or disable it and select for every daytime an image manually
## 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.
3. Configure it to your
- You can apply the setted settings without closing the window if you click on "Apply"
4. If your config is complete, click on "OK"
---
## 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)
---
## Included image sets
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
suntimes = Suntimes()
location_thread = Location()
background_settings = Gio.Settings.new("org.cinnamon.desktop.background")
class Loop():
def __init__(self) -> None:
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
if self.prefs.period_source == PeriodSourceEnum.NETWORKLOCATION:
location_thread.start()
location_thread.join()
current_location = self.location.run()
location = location_thread.result
suntimes.calc_suntimes(float(location["latitude"]), float(location["longitude"]))
self.start_times = suntimes.day_periods
self.suntimes.calc_suntimes(float(current_location["latitude"]), float(current_location["longitude"]))
self.start_times = self.suntimes.day_periods
# Position is given by user
elif self.prefs.period_source == PeriodSourceEnum.CUSTOMLOCATION:
suntimes.calc_suntimes(float(self.prefs.latitude_custom), float(self.prefs.longitude_custom))
self.start_times = suntimes.day_periods
self.suntimes.calc_suntimes(float(self.prefs.latitude_custom), float(self.prefs.longitude_custom))
self.start_times = self.suntimes.day_periods
# No position, concrete times
else:
@@ -71,10 +67,10 @@ class Loop():
break
# 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
background_settings['picture-options'] = self.prefs.picture_aspect
self.background_settings['picture-options'] = self.prefs.picture_aspect
self.set_background_gradient()
@@ -94,14 +90,14 @@ class Loop():
bottom_color = pix[width / 2, height - 1]
# Create the gradient
background_settings['color-shading-type'] = "vertical"
self.background_settings['color-shading-type'] = "vertical"
if self.prefs.dynamic_background_color:
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['primary-color'] = f"#{top_color[0]:x}{top_color[1]:x}{top_color[2]:x}"
self.background_settings['secondary-color'] = f"#{bottom_color[0]:x}{bottom_color[1]:x}{bottom_color[2]:x}"
else:
background_settings['primary-color'] = "#000000"
background_settings['secondary-color'] = "#000000"
self.background_settings['primary-color'] = "#000000"
self.background_settings['secondary-color'] = "#000000"
# Needed for JavaScript

View File

@@ -30,15 +30,17 @@ class Preferences:
############################################################
def __init__(self) -> None:
self.builder = Gtk.Builder()
self.builder.add_from_file(GLADE_URI)
self.builder.connect_signals(self)
# Objects from external scripts
self.time_bar_chart = Time_Bar_Chart()
self.c_prefs = Cinnamon_Pref_Handler()
self.suntimes = Suntimes()
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 ##########
@@ -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_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.etr_longitude = self.builder.get_object("etr_longitude")
self.etr_latitude = self.builder.get_object("etr_latitude")
self.img_bar_times = self.builder.get_object("img_bar_times")
self.etr_longitude: Gtk.Entry = self.builder.get_object("etr_longitude")
self.etr_latitude: Gtk.Entry = self.builder.get_object("etr_latitude")
self.img_bar_times: Gtk.Image = self.builder.get_object("img_bar_times")
self.spb_periods_hour: list[Gtk.SpinButton] = [
self.builder.get_object("spb_period_1_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)
# Start a thread to get the current location
locationThread = Location()
locationThread.start()
locationThread.join()
location = locationThread.result
# Display the location in the UI
self.lb_current_location.set_text("Latitude: " + location["latitude"] + \
", Longitude: " + location["longitude"])
current_location = self.location.run()
self.lb_current_location.set_text("Latitude: " + current_location["latitude"] + \
", Longitude: " + current_location["longitude"])
# Store the location to the preferences
self.c_prefs.latitude_auto = float(location["latitude"])
self.c_prefs.longitude_auto = float(location["longitude"])
self.c_prefs.latitude_auto = float(current_location["latitude"])
self.c_prefs.longitude_auto = float(current_location["longitude"])
self.refresh_chart()

View File

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

View File

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