Skip to content

Commit

Permalink
NightLightSwitch v1.0.1 - Fixes #6800: No longer requires the gir1.2-…
Browse files Browse the repository at this point in the history
…gweather-4.0 package (#6801)
  • Loading branch information
claudiux authored Jan 24, 2025
1 parent 14ab721 commit f2c3ce4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const Applet = imports.ui.applet;
const Gio = imports.gi.Gio;
const GWeather = imports.gi.GWeather;
//~ const GWeather = imports.gi.GWeather;
const PopupMenu = imports.ui.popupMenu;
const Util = imports.misc.util;
const St = imports.gi.St;
Expand Down Expand Up @@ -176,21 +176,22 @@ class NightLightSwitch extends Applet.IconApplet {
lat = lat.unpack(); // type (d)
lon = lon.unpack(); // type (d)
//~ global.log("lat: "+lat+" - lon: "+lon);
if (Math.round(lat) == 91 || Math.round(lon) == 181) {
this.sunrise = 6;
this.sunset = 12;
} else {
this.weather = GWeather.Info.new(GWeather.Location.new_detached("local", null, lat, lon));
let sunrise = this.weather.get_sunrise().trim().split(":");
let sunset = this.weather.get_sunset().trim().split(":");
//~ global.log("sunrise: " + sunrise);
//~ global.log("sunset: " + sunset);
this.sunrise = parseInt(sunrise[0][0])*10+parseInt(sunrise[0][1])+(parseInt(sunrise[0][3])*10+parseInt(sunrise[0][4]))/60;
this.sunset = parseInt(sunset[0][0])*10+parseInt(sunset[0][1])+(parseInt(sunset[0][3])*10+parseInt(sunset[0][4]))/60;
}
this.sunrise = Math.round(this.sunrise * 4)/4;
this.sunset = Math.round(this.sunset * 4)/4;
//~ global.log("sunrise: " + this.sunrise + " - sunset: " + this.sunset);

//~ if (Math.round(lat) == 91 || Math.round(lon) == 181) {
//~ this.sunrise = 6;
//~ this.sunset = 12;
//~ } else {
//~ this.weather = GWeather.Info.new(GWeather.Location.new_detached("local", null, lat, lon));
//~ let sunrise = this.weather.get_sunrise().trim().split(":");
//~ let sunset = this.weather.get_sunset().trim().split(":");
//~ //global.log("sunrise: " + sunrise);
//~ //global.log("sunset: " + sunset);
//~ this.sunrise = parseInt(sunrise[0][0])*10+parseInt(sunrise[0][1])+(parseInt(sunrise[0][3])*10+parseInt(sunrise[0][4]))/60;
//~ this.sunset = parseInt(sunset[0][0])*10+parseInt(sunset[0][1])+(parseInt(sunset[0][3])*10+parseInt(sunset[0][4]))/60;
//~ }
//~ this.sunrise = Math.round(this.sunrise * 4)/4;
//~ this.sunset = Math.round(this.sunset * 4)/4;
//~ //global.log("sunrise: " + this.sunrise + " - sunset: " + this.sunset);

let items = this._applet_context_menu._getMenuItems();
if (this.context_menu_item_configure == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
### v1.0.1~20250124
* Fixes #6800. No longer requires the gir1.2-gweather-4.0 package.

### v1.0.0~20250123
* Fully functional.
* Needs the gir1.2-gweather-4.0 package.
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"uuid": "NightLightSwitch@claudiux",
"name": "Night Light Switch",
"author": "claudiux",
"version": "1.0.0"
"version": "1.0.1"
}

0 comments on commit f2c3ce4

Please sign in to comment.