Add check-week.ps1 and check-year.ps1

This commit is contained in:
Markus 2021-12-11 17:44:30 +01:00
parent 8ea938067f
commit 42aab1440b
5 changed files with 47 additions and 3 deletions

View File

@ -32,7 +32,7 @@ When finished say: *"Computer, close [app]"* to close the application.
*"Computer, check [item]."*
--------------------------
Lets the computer check something, replace [item] by: `Bitcoin rate`, `Christmas`, `CPU`, `date`, `dawn`, `DNS`, `drives`, `dusk`, `Easter Sunday`, `Earth` (fun), `Ether rate`, `headlines`, `Independence Day`, `ISS position`, `midnight`, `moon phase`, `New Year`, `noon`, `operating system`, `ping`, `Santa`, `sunrise`, `sunset`, `swap space`, `tea time`, `Tether rate`, `time`, `time zone`, `up-time`, `VPN`, `weather`, or `zenith`.
Lets the computer check something, replace [item] by: `Bitcoin rate`, `Christmas`, `CPU`, `date`, `dawn`, `DNS`, `drives`, `dusk`, `Easter Sunday`, `Earth` (fun), `Ether rate`, `headlines`, `Independence Day`, `ISS position`, `midnight`, `moon phase`, `New Year`, `noon`, `operating system`, `ping`, `Santa`, `sunrise`, `sunset`, `swap space`, `tea time`, `Tether rate`, `time`, `time zone`, `up-time`, `VPN`, `weather`, `week`, `year`, or `zenith`.
*"Computer, open [letter] drive."*

22
Scripts/check-week.ps1 Normal file
View File

@ -0,0 +1,22 @@
<#
.SYNOPSIS
Determines the week number
.DESCRIPTION
This script determines and speaks the current week number by text-to-speech (TTS).
.EXAMPLE
PS> ./check-week
It's week #4.
.NOTES
Author: Markus Fleschutz · License: CC0
.LINK
https://github.com/fleschutz/PowerShell
#>
try {
$WeekNo = (get-date -UFormat %V)
& "$PSScriptRoot/give-reply.ps1" "It's week #$WeekNo."
exit 0 # success
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
exit 1
}

22
Scripts/check-year.ps1 Normal file
View File

@ -0,0 +1,22 @@
<#
.SYNOPSIS
Determines the current year
.DESCRIPTION
This script determines and speaks the current year by text-to-speech (TTS).
.EXAMPLE
PS> ./check-year
It's 2021.
.NOTES
Author: Markus Fleschutz · License: CC0
.LINK
https://github.com/fleschutz/PowerShell
#>
try {
$Year = (Get-Date).Year
& "$PSScriptRoot/give-reply.ps1" "It's $Year."
exit 0 # success
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
exit 1
}

View File

@ -37,7 +37,7 @@ try {
foreach ($Script in $Scripts) {
$ScriptName = $Script.basename
$Keyword = $ScriptName -replace "-"," "
"serenade.global().command(`"$($WakeWord.toLower()) $Keyword`",async(api)=>{await api.focusApplication(`"$Application`");await api.typeText(`"$ScriptName.ps1`");await api.pressKey(`"return`");});" | Add-Content "$TargetFile"
"serenade.global().command(`"$($WakeWord.toLower()) $Keyword`",async(api)=>{await api.focusApplication(`"$Application`");await api.pressKey(`"return`");await api.typeText(`"$ScriptName.ps1`");await api.pressKey(`"return`");});" | Add-Content "$TargetFile"
}
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds

View File

@ -11,7 +11,7 @@
https://github.com/fleschutz/PowerShell
#>
$Reply = "Good night to you, too.", "Good night to you, my friend.", "Have a good night. Sleep well.", "Good night and sweet dreams." | Get-Random
$Reply = "Good night to you too.", "Good night to you my friend.", "Have a good night. Sleep well.", "Good night and sweet dreams." | Get-Random
& "$PSScriptRoot/give-reply.ps1" "$Reply"
exit 0 # success