-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopenWindows.js
More file actions
59 lines (50 loc) · 1.7 KB
/
openWindows.js
File metadata and controls
59 lines (50 loc) · 1.7 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// This widget can handle your reminders for opening windows schedueled.
// Please keep in mind that I haven't optimised the code yet. But maybe it can help you to keep an eye on your windows to
// minimize the Corona infection risk.
let minutes = 15
let titleFontSize = 22
manageInfoWidget()
if(!config.runsInWidget) {
manageReminder()
}
Script.setWidget(await manageHomeWidget())
Script.complete()
async function manageInfoWidget() {
let widget = new ListWidget()
widget.backgroundColor = Color.blue()
let title = widget.addText("⚗️ Lüften".toUpperCase())
title.font = Font.boldRoundedSystemFont(titleFontSize)
widget.addSpacer()
let description = widget.addText("✅ Erinnerung eingerichtet (öffnen)")
description.font = Font.mediumSystemFont(14)
title.textColor = Color.white()
description.textColor = Color.white()
widget.presentSmall()
}
async function manageHomeWidget() {
let widget = new ListWidget()
widget.backgroundColor = Color.blue()
let title = widget.addText("⚗️ Lüften".toUpperCase())
title.font = Font.boldRoundedSystemFont(titleFontSize)
widget.addSpacer()
let description = widget.addText("An Fenster öffnen erinnern")
description.font = Font.mediumSystemFont(14)
title.textColor = Color.white()
description.textColor = Color.white()
return widget
}
async function manageReminder() {
let reminder = new Reminder()
reminder.calendar = await getCalendar()
reminder.title = "Fenster öffnen"
reminder.dueDate = await getReminderDate()
reminder.save()
}
async function getCalendar() {
let c = Calendar.findOrCreateForReminders("Lüften")
return c
}
async function getReminderDate() {
let d = new Date(Date.now() + (1000 * 60 * minutes))
return d
}