-
Notifications
You must be signed in to change notification settings - Fork 0
/
pomodoro.ps1
72 lines (60 loc) · 2.2 KB
/
pomodoro.ps1
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
66
67
68
69
70
71
#Requires -Modules PoshNotify
[CmdletBinding(DefaultParameterSetName = 'Stack')]
param (
[datetime]
$EndDate = (Get-Date '16:00'),
[Parameter(ParameterSetName = 'Random')]
[Switch]
$Random
)
[String[]]$Item = 'JavaScript','Research','PSKoans','Blog','Python','PowerShell','C#','dbachecks','DBAFundamentals','Entity Framework','Containers','R'
$TimeHash = @{
'Work' = 25
'Feedly' = 5
'Long Break' = 20
}
$Item | ForEach-Object -Process {
$TimeHash[$_] = 20
}
$ItemStack = [System.Collections.Generic.Stack[string]]::new()
[Int]$Counter = 0
[Int]$WorkCounter = 0
while ((Get-Date) -lt ($EndDate)) {
if ($ItemStack.Count -eq 0) {
foreach ($todo in (Get-Random -InputObject $Item -Count $Item.Count)) {
$ItemStack.Push($todo)
}
}
$CurrentAction = switch ($Counter) {
{$_ % 5 -eq 0} { 'Long Break'; break }
{$_ % 3 -eq 0} {
if ($PSBoundParameters.ContainsKey('Random') -and $Random) {
Get-Random -InputObject $Item
} else {
$ItemStack.Pop()
}
break
}
Default {'Work'}
}
if ($CurrentAction -eq 'Work') {$WorkCounter++}
[PSCustomObject]@{
Action = $CurrentAction
StartTime = Get-Date
PSTypeName = 'Pomodoro'
Mark = if ((($WorkCounter % 2) -ne 0) -and $WorkCounter -ne 1 -and $CurrentAction -eq 'Work') { 'X' }
}
Send-OSNotification -Title $CurrentAction -Body "Starting : $(Get-Date) - Finishing : $((Get-Date).AddMinutes(($TimeHash[$CurrentAction])))"
Start-Sleep -Seconds (New-TimeSpan -Minutes ($TimeHash[$CurrentAction])).TotalSeconds
[Console]::Beep()
[PSCustomObject]@{
Action = ($CurrentAction = 'Feedly')
StartTime = Get-Date
PSTypeName = 'Pomodoro'
Mark = $null
}
Send-OSNotification -Title 'Feedly' -Body "Starting : $(Get-Date) - Finishing : $((Get-Date).AddMinutes(($TimeHash[$CurrentAction])))"
Start-Sleep -Seconds (New-TimeSpan -Minutes ($TimeHash[$CurrentAction])).TotalSeconds
[Console]::Beep()
$Counter++
}