Skip to content

Commit bcc55cf

Browse files
author
queenkjuul
committed
Add basic weather information to screensaver
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
1 parent f4fb467 commit bcc55cf

File tree

11 files changed

+770
-27
lines changed

11 files changed

+770
-27
lines changed

cinnamon-screensaver.pot

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,61 +8,61 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2022-12-02 21:29+0000\n"
11+
"POT-Creation-Date: 2024-11-22 04:11-0600\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
1515
"Language: \n"
1616
"MIME-Version: 1.0\n"
17-
"Content-Type: text/plain; charset=CHARSET\n"
17+
"Content-Type: text/plain; charset=UTF-8\n"
1818
"Content-Transfer-Encoding: 8bit\n"
1919
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
2020

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

25-
#: src/cinnamon-screensaver-command.py:43
25+
#: src/cinnamon-screensaver-command.py:45
2626
msgid "Query the state of the screensaver"
2727
msgstr ""
2828

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

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

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

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

45-
#: src/cinnamon-screensaver-command.py:53
45+
#: src/cinnamon-screensaver-command.py:55
4646
msgid "Version of this application"
4747
msgstr ""
4848

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

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

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

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

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

83-
#: src/passwordEntry.py:23 src/unlock.py:216
83+
#: src/passwordEntry.py:23 src/unlock.py:215
8484
msgid "Please enter your password..."
8585
msgstr ""
8686

@@ -92,52 +92,56 @@ msgstr ""
9292
msgid "Switch User"
9393
msgstr ""
9494

95-
#: src/unlock.py:189
95+
#: src/unlock.py:188
9696
msgid "Incorrect password"
9797
msgstr ""
9898

99-
#: src/unlock.py:206
99+
#: src/unlock.py:205
100100
msgid "Checking..."
101101
msgstr ""
102102

103-
#: src/unlock.py:250
103+
#: src/unlock.py:249
104104
msgid "You have the Caps Lock key on."
105105
msgstr ""
106106

107+
#: src/weather.py:102
108+
msgid "in"
109+
msgstr ""
110+
107111
#. This is the first line of text for the backup-locker, explaining how to switch to tty
108112
#. and run 'cinnamon-unlock-desktop' command. This appears if the screensaver crashes.
109-
#: backup-locker/cs-backup-locker.c:255
113+
#: backup-locker/cs-backup-locker.c:306
110114
msgid "Something went wrong with the screensaver."
111115
msgstr ""
112116

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

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

124128
#. (list continued)
125-
#: backup-locker/cs-backup-locker.c:278
129+
#: backup-locker/cs-backup-locker.c:329
126130
msgid "Log in by typing your user name followed by your password."
127131
msgstr ""
128132

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

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

140144
#. (end section) Final words after the list of steps
141-
#: backup-locker/cs-backup-locker.c:287
145+
#: backup-locker/cs-backup-locker.c:338
142146
msgid "If you can reproduce this behavior, please file a report here:"
143147
msgstr ""

src/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ app_py = [
3232
'status.py',
3333
'unlock.py',
3434
'volumeControl.py',
35+
'weather.py'
3536
]
3637

3738
app_css = [

src/stage.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from util import utils, trackers, settings
2121
from util.eventHandler import EventHandler
2222
from util.utils import DEBUG
23+
from weather import WeatherWidget
2324

2425
class Stage(Gtk.Window):
2526
"""
@@ -69,6 +70,7 @@ def __init__(self, manager, away_message):
6970
self.overlay = None
7071
self.clock_widget = None
7172
self.albumart_widget = None
73+
self.weather_widget = None
7274
self.unlock_dialog = None
7375
self.audio_panel = None
7476
self.info_panel = None
@@ -291,6 +293,11 @@ def setup_delayed_components(self, data=None):
291293
except Exception as e:
292294
print("Problem setting up albumart widget: %s" % str(e))
293295
self.albumart_widget = None
296+
try:
297+
self.setup_weather()
298+
except Exception as e:
299+
print("Problem setting up weather widget: %s" % str(e))
300+
self.weather_widget = None
294301
try:
295302
self.setup_status_bars()
296303
except Exception as e:
@@ -324,6 +331,13 @@ def destroy_children(self):
324331
except Exception as e:
325332
print(e)
326333

334+
try:
335+
if self.weather_widget is not None:
336+
self.weather_widget.stop_positioning()
337+
self.weather_widget.destroy()
338+
except Exception as e:
339+
print(e)
340+
327341
try:
328342
if self.info_panel is not None:
329343
self.info_panel.destroy()
@@ -345,6 +359,7 @@ def destroy_children(self):
345359
self.unlock_dialog = None
346360
self.clock_widget = None
347361
self.albumart_widget = None
362+
self.weather_widget = None
348363
self.info_panel = None
349364
self.audio_panel = None
350365
self.osk = None
@@ -504,6 +519,23 @@ def setup_albumart(self):
504519
if settings.get_show_albumart():
505520
self.albumart_widget.start_positioning()
506521

522+
def setup_weather(self):
523+
"""
524+
Construct the Weather widget and add it to the overlay, but only actually
525+
show it if we're a) Not running a plug-in, and b) The user wants it via
526+
preferences.
527+
528+
Initially invisible, regardless - its visibility is controlled via its
529+
own positioning timer.
530+
"""
531+
self.weather_widget = WeatherWidget(None, status.screen.get_mouse_monitor())
532+
self.add_child_widget(self.weather_widget)
533+
534+
self.floaters.append(self.weather_widget)
535+
536+
if settings.get_show_albumart():
537+
self.weather_widget.start_positioning()
538+
507539
def setup_osk(self):
508540
self.osk = OnScreenKeyboard()
509541

src/util/geojs.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import json
2+
from types import SimpleNamespace
3+
4+
import requests
5+
6+
from util.location import LocationProvider, LocationData
7+
8+
URL = "https://get.geojs.io/v1/ip/geo.json"
9+
10+
class GeoJSLocationProvider(LocationProvider):
11+
"""
12+
LocationProvider implementation for geojs.io
13+
"""
14+
15+
def __init__(self):
16+
pass
17+
18+
@staticmethod
19+
def GetLocation() -> LocationData:
20+
response = requests.get(URL)
21+
22+
data = json.loads(response.text, object_hook=lambda d: SimpleNamespace(**d))
23+
24+
return LocationData(float(data.latitude), float(data.longitude), data.city, data.country, data.timezone, data.city)

src/util/location.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from abc import ABC, abstractmethod
2+
from dataclasses import dataclass
3+
from typing import Optional
4+
5+
6+
@dataclass
7+
class LocationData:
8+
lat: float
9+
lon: float
10+
city: Optional[str] = None
11+
country: Optional[str] = None
12+
timeZone: Optional[str] = None
13+
entryText: Optional[str] = None
14+
15+
16+
class LocationProvider(ABC):
17+
@abstractmethod
18+
def GetLocation(self) -> LocationData:
19+
pass

src/util/meson.build

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ app_py = [
33
'eventHandler.py',
44
'fader.py',
55
'focusNavigator.py',
6+
'geojs.py',
67
'keybindings.py',
8+
'location.py',
9+
'openweathermap.py',
710
'settings.py',
811
'trackers.py',
9-
'utils.py'
12+
'utils.py',
13+
'weather.py',
14+
'weather_types.py'
1015
]
1116

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

0 commit comments

Comments
 (0)