@@ -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
6060the command line options above.
6161
62- ### Example
62+ ## Examples
6363
6464On 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
0 commit comments