Skip to content

Commit c6e3d8d

Browse files
committed
Merge branch 'main' of https://github.com/woodcoder/circa into main
2 parents ef7dc27 + 525882e commit c6e3d8d

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

README.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,52 @@ per user by using a [config file](circa.conf). This should be placed in
5959
`/etc/circa.conf` or/and `~/.circa/config`. These defaults are overridable by
6060
the command line options above.
6161

62-
### Example
62+
## Examples
6363

6464
On macOS, you could run the following to pop up a reminder to charge your latop for a couple of hours:
6565

6666
```
67-
./ca -d 120 8 osascript -e 'display notification "Why not plug in your charger?" with title "Low Carbon Energy Available"'
67+
ca -d 120 8 osascript -e 'display notification "Why not plug in your charger?" with title "Lower Carbon Energy Available"'
6868
```
6969

70+
If you install it with WSL under Windows, you can do something similar with this PowerShell script:
71+
72+
```
73+
function Show-Notification {
74+
param (
75+
[string] $ToastText1,
76+
[string] $ToastText2
77+
)
78+
79+
$Notification = "<toast>
80+
<visual>
81+
<binding template='ToastText02'>
82+
<text id='1'>$($ToastText1)</text>
83+
<text id='2'>$($ToastText2)</text>
84+
</binding>
85+
</visual>
86+
</toast>"
87+
88+
$NotificationXml = New-Object Windows.Data.Xml.Dom.XmlDocument
89+
$NotificationXml.LoadXml($Notification)
90+
91+
$Toast = [Windows.UI.Notifications.ToastNotification]::new($NotificationXml)
92+
$Toast.Tag = "Carbon Aware"
93+
$Toast.Group = "Carbon Aware"
94+
$Toast.ExpirationTime = [DateTimeOffset]::Now.AddMinutes(1)
95+
96+
$Notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Carbon Aware")
97+
$Notifier.Show($Toast);
98+
}
99+
100+
wsl ca -d 120 8
101+
Show-Notification "Lower Carbon Energy Available" "Why not plug in your charger?"
102+
```
103+
104+
Save the above in a file (e.g. `carbon-aware.ps1`) and run it from a Windows
105+
PowerShell prompt. You may need to run
106+
`Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass`
107+
in your PowerShell window first.
70108

71109
## Motivation
72110

circa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ void parse_response(response_t *response, void *wait_seconds) {
358358
.tm_min = m,
359359
.tm_sec = s};
360360
time_t now, optimal_time;
361-
optimal_time = timegm(&timestamp_tm); // or _mkgmtime() on windows
361+
optimal_time = timegm(&timestamp_tm);
362362
time(&now);
363363
*(double *)wait_seconds = difftime(optimal_time, now);
364364
}

0 commit comments

Comments
 (0)