Main loop, update location, dynamic wallpaper change
This commit is contained in:
14
cinnamon-dynamic-wallpaper@TobiZog/scripts/location.js
Normal file
14
cinnamon-dynamic-wallpaper@TobiZog/scripts/location.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const Soup = imports.gi.Soup;
|
||||
|
||||
|
||||
function estimateLocation() {
|
||||
let sessionSync = new Soup.SessionSync();
|
||||
let msg = Soup.Message.new('GET', "https://get.geojs.io/v1/ip/geo.json");
|
||||
sessionSync.send_message(msg);
|
||||
|
||||
if (msg.status_code == 200) {
|
||||
return JSON.parse(msg.response_body.data);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -24,10 +24,7 @@ const J2000 = 2451545
|
||||
|
||||
function fromJulian(j) {
|
||||
let ms_date = (j + 0.5 - J1970) * DAYMS
|
||||
var utc = new Date();
|
||||
var offset = utc.getTimezoneOffset()
|
||||
|
||||
return new Date(ms_date - offset * 60000)
|
||||
return new Date(ms_date)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,4 +155,4 @@ function calcTimePeriod(latitude, longitude) {
|
||||
addMinutesToTime(tomorrowSunEventsDay.dawn, -1)
|
||||
],
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user