-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchameleond.ps1
44 lines (33 loc) · 997 Bytes
/
chameleond.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<#
Chameleon - An automated bright / dark mode toggle
service that follows the sun.
Authors:
Simon Olofsson
dotchetter@protonmail.ch
https://github.com/dotchetter
Michael Hällström
https://github.com/yousernaym
Date:
2021-03-17
Backend logic file, invoked as daemon by chameleond
#>
Import-Module .\helpers.ps1
$location = getLocationFromWindows10LocationApi
$sundata = getSunSetSunRiseDataFromPublicApi $location
$previousCheck = Get-Date
$sundataUpdatedTimestamp = Get-Date
while (1)
{
if (((Get-Date) - $sundataUpdatedTimestamp).days)
{
$location = getLocationFromWindows10LocationApi
$sundata = getSunSetSunRiseDataFromPublicApi $location
}
$script:sunTheme = evaluateBrightOrDarkmode $sundata
if ($previousTheme -ne $script:sunTheme)
{
[Themes]::sun | setTheme
$previousTheme = $script:sunTheme
}
Start-Sleep -Seconds ($INTERVAL_MINUTES * 60)
}