Bugfixes, Readme
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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"]
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user