-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetEvents.sh
65 lines (58 loc) · 1.41 KB
/
getEvents.sh
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
59
60
61
62
63
64
65
ics_url="your_url"
# Get today's date in YYYYMMDD format
today=$(date +%Y%m%d)
# Use curl to fetch the ICS data and process it
curl -s "$ics_url" | awk -v date="$today" '
BEGIN {
inEvent = 0;
matched = 0;
}
/BEGIN:VEVENT/ {
inEvent = 1;
matched = 0; # Reset the matched flag at the beginning of a new event
start = ""; # Reset variables at the start of a new event
end = "";
summary = "";
}
/END:VEVENT/ {
if (matched) {
# Extract hour and minute from start and end variables
timeshift="2"
start1 = substr(start, 10, 2);
start2 = substr(start, 12, 2);
start1= start1+timeshift;
end1 = substr(end, 10, 2);
end2 = substr(end, 12, 2);
end1= end1+timeshift;
# Output the data in the specified order
print "Termin: " summary;
print "Beginn: " start1 ":" start2;
print "Ende: " end1 ":" end2;
print ""; # Print an empty line to separate events
}
inEvent = 0;
}
/^DTSTART:/ {
if (index($0, date) > 0) {
matched = 1;
}
# Store the start time without the label
sub(/^DTSTART:/, "", $0);
if (matched) {
start = $0;
}
}
/^DTEND:/ {
# Store the end time without the label
sub(/^DTEND:/, "", $0);
if (matched) {
end = $0;
}
}
/^SUMMARY:/ {
# Store the summary without the label
sub(/^SUMMARY:/, "", $0);
if (matched) {
summary = $0;
}
}'