Skip to content

Commit

Permalink
Add basic weather information to screensaver
Browse files Browse the repository at this point in the history
Get basic temperature, conditions, location working with scaled icon

Code cleanup

Add IP Geolocation to weather component

Cleanup, settings integrations, bugfixes, translation

Fix Localization

cleanup
  • Loading branch information
queenkjuul committed Nov 22, 2024
1 parent f4fb467 commit bcbd584
Show file tree
Hide file tree
Showing 11 changed files with 737 additions and 26 deletions.
54 changes: 29 additions & 25 deletions cinnamon-screensaver.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,61 +8,61 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-12-02 21:29+0000\n"
"POT-Creation-Date: 2024-11-22 04:11-0600\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"

#: src/cinnamon-screensaver-command.py:41
#: src/cinnamon-screensaver-command.py:43
msgid "Causes the screensaver to exit gracefully"
msgstr ""

#: src/cinnamon-screensaver-command.py:43
#: src/cinnamon-screensaver-command.py:45
msgid "Query the state of the screensaver"
msgstr ""

#: src/cinnamon-screensaver-command.py:45
#: src/cinnamon-screensaver-command.py:47
msgid "Query the length of time the screensaver has been active"
msgstr ""

#: src/cinnamon-screensaver-command.py:47
#: src/cinnamon-screensaver-command.py:49
msgid "Tells the running screensaver process to lock the screen immediately"
msgstr ""

#: src/cinnamon-screensaver-command.py:49
#: src/cinnamon-screensaver-command.py:51
msgid "Turn the screensaver on (blank the screen)"
msgstr ""

#: src/cinnamon-screensaver-command.py:51
#: src/cinnamon-screensaver-command.py:53
msgid "If the screensaver is active then deactivate it (un-blank the screen)"
msgstr ""

#: src/cinnamon-screensaver-command.py:53
#: src/cinnamon-screensaver-command.py:55
msgid "Version of this application"
msgstr ""

#: src/cinnamon-screensaver-command.py:55
#: src/cinnamon-screensaver-command.py:57
msgid "Message to be displayed in lock screen"
msgstr ""

#: src/cinnamon-screensaver-command.py:105
#: src/cinnamon-screensaver-command.py:106
msgid "The screensaver is active\n"
msgstr ""

#: src/cinnamon-screensaver-command.py:107
#: src/cinnamon-screensaver-command.py:108
msgid "The screensaver is inactive\n"
msgstr ""

#: src/cinnamon-screensaver-command.py:111
#: src/cinnamon-screensaver-command.py:112
msgid "The screensaver is not currently active.\n"
msgstr ""

#: src/cinnamon-screensaver-command.py:113
#: src/cinnamon-screensaver-command.py:114
#, python-format
msgid "The screensaver has been active for %d second.\n"
msgid_plural "The screensaver has been active for %d seconds.\n"
Expand All @@ -80,7 +80,7 @@ msgid ""
"prior to this occurring."
msgstr ""

#: src/passwordEntry.py:23 src/unlock.py:216
#: src/passwordEntry.py:23 src/unlock.py:215
msgid "Please enter your password..."
msgstr ""

Expand All @@ -92,52 +92,56 @@ msgstr ""
msgid "Switch User"
msgstr ""

#: src/unlock.py:189
#: src/unlock.py:188
msgid "Incorrect password"
msgstr ""

#: src/unlock.py:206
#: src/unlock.py:205
msgid "Checking..."
msgstr ""

#: src/unlock.py:250
#: src/unlock.py:249
msgid "You have the Caps Lock key on."
msgstr ""

#: src/weather.py:102
msgid "in"
msgstr ""

#. This is the first line of text for the backup-locker, explaining how to switch to tty
#. and run 'cinnamon-unlock-desktop' command. This appears if the screensaver crashes.
#: backup-locker/cs-backup-locker.c:255
#: backup-locker/cs-backup-locker.c:306
msgid "Something went wrong with the screensaver."
msgstr ""

#. (continued) This is a subtitle
#: backup-locker/cs-backup-locker.c:265
#: backup-locker/cs-backup-locker.c:316
msgid "We'll help you get your desktop back"
msgstr ""

#. (new section) Bulleted list of steps to take to unlock the desktop;
#: backup-locker/cs-backup-locker.c:276
#: backup-locker/cs-backup-locker.c:327
#, c-format
msgid "Switch to a console using <Control-Alt-F%u>."
msgstr ""

#. (list continued)
#: backup-locker/cs-backup-locker.c:278
#: backup-locker/cs-backup-locker.c:329
msgid "Log in by typing your user name followed by your password."
msgstr ""

#. (list continued)
#: backup-locker/cs-backup-locker.c:280
#: backup-locker/cs-backup-locker.c:331
msgid "At the prompt, type 'cinnamon-unlock-desktop' and press Enter."
msgstr ""

#. (list continued)
#: backup-locker/cs-backup-locker.c:282
#: backup-locker/cs-backup-locker.c:333
#, c-format
msgid "Switch back to your unlocked desktop using <Control-Alt-F%u>."
msgstr ""

#. (end section) Final words after the list of steps
#: backup-locker/cs-backup-locker.c:287
#: backup-locker/cs-backup-locker.c:338
msgid "If you can reproduce this behavior, please file a report here:"
msgstr ""
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ app_py = [
'status.py',
'unlock.py',
'volumeControl.py',
'weather.py'
]

app_css = [
Expand Down
32 changes: 32 additions & 0 deletions src/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from util import utils, trackers, settings
from util.eventHandler import EventHandler
from util.utils import DEBUG
from weather import WeatherWidget

class Stage(Gtk.Window):
"""
Expand Down Expand Up @@ -69,6 +70,7 @@ def __init__(self, manager, away_message):
self.overlay = None
self.clock_widget = None
self.albumart_widget = None
self.weather_widget = None
self.unlock_dialog = None
self.audio_panel = None
self.info_panel = None
Expand Down Expand Up @@ -291,6 +293,11 @@ def setup_delayed_components(self, data=None):
except Exception as e:
print("Problem setting up albumart widget: %s" % str(e))
self.albumart_widget = None
try:
self.setup_weather()
except Exception as e:
print("Problem setting up weather widget: %s" % str(e))
self.weather_widget = None
try:
self.setup_status_bars()
except Exception as e:
Expand Down Expand Up @@ -324,6 +331,13 @@ def destroy_children(self):
except Exception as e:
print(e)

try:
if self.weather_widget is not None:
self.weather_widget.stop_positioning()
self.weather_widget.destroy()
except Exception as e:
print(e)

try:
if self.info_panel is not None:
self.info_panel.destroy()
Expand All @@ -345,6 +359,7 @@ def destroy_children(self):
self.unlock_dialog = None
self.clock_widget = None
self.albumart_widget = None
self.weather_widget = None
self.info_panel = None
self.audio_panel = None
self.osk = None
Expand Down Expand Up @@ -504,6 +519,23 @@ def setup_albumart(self):
if settings.get_show_albumart():
self.albumart_widget.start_positioning()

def setup_weather(self):
"""
Construct the Weather widget and add it to the overlay, but only actually
show it if we're a) Not running a plug-in, and b) The user wants it via
preferences.
Initially invisible, regardless - its visibility is controlled via its
own positioning timer.
"""
self.weather_widget = WeatherWidget(None, status.screen.get_mouse_monitor())
self.add_child_widget(self.weather_widget)

self.floaters.append(self.weather_widget)

if settings.get_show_albumart():
self.weather_widget.start_positioning()

def setup_osk(self):
self.osk = OnScreenKeyboard()

Expand Down
24 changes: 24 additions & 0 deletions src/util/geojs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import json
from types import SimpleNamespace

import requests

from util.location import LocationProvider, LocationData

URL = "https://get.geojs.io/v1/ip/geo.json"

class GeoJSLocationProvider(LocationProvider):
"""
LocationProvider implementation for geojs.io
"""

def __init__(self):
pass

@staticmethod
def GetLocation() -> LocationData:
response = requests.get(URL)

data = json.loads(response.text, object_hook=lambda d: SimpleNamespace(**d))

return LocationData(float(data.latitude), float(data.longitude), data.city, data.country, data.timezone, data.city)
19 changes: 19 additions & 0 deletions src/util/location.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Optional


@dataclass
class LocationData:
lat: float
lon: float
city: Optional[str] = None
country: Optional[str] = None
timeZone: Optional[str] = None
entryText: Optional[str] = None


class LocationProvider(ABC):
@abstractmethod
def GetLocation(self) -> LocationData:
pass
7 changes: 6 additions & 1 deletion src/util/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ app_py = [
'eventHandler.py',
'fader.py',
'focusNavigator.py',
'geojs.py',
'keybindings.py',
'location.py',
'openweathermap.py',
'settings.py',
'trackers.py',
'utils.py'
'utils.py',
'weather.py',
'weather_types.py'
]

install_data(app_py, install_dir: join_paths(pkgdatadir, 'util'))
Loading

0 comments on commit bcbd584

Please sign in to comment.