-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpm.ps1
51 lines (41 loc) · 1.54 KB
/
pm.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
function Show-Notification {
Param ( [string]$Message = "Notification", [string]$Title = "Title" )
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
Remove-Event BalloonClicked_event -ea SilentlyContinue
Unregister-Event -SourceIdentifier BalloonClicked_event -ea silentlycontinue
Remove-Event BalloonClosed_event -ea SilentlyContinue
Unregister-Event -SourceIdentifier BalloonClosed_event -ea silentlycontinue
$notification = New-Object System.Windows.Forms.NotifyIcon
$notification.Icon = [System.Drawing.SystemIcons]::Information
$notification.BalloonTipIcon = "Info"
$notification.BalloonTipTitle = $Title
$notification.BalloonTipText = $Message
$notification.Visible = $True
$notification.ShowBalloonTip(600)
}
Function Start-Pomodoro {
<#
.SYNOPSIS
Simple Pomodoro Timer
.EXAMPLE
Start-Pomodoro
.EXAMPLE
Start-Pomodoro 5
.PARAMETER Minutes
Time in Minutes. Default is 25
#>
Param (
[int]$Minutes = 25
)
$seconds = $Minutes * 60
for($i = $seconds; $i -gt 0; $i = $i - 1)
{
$percentComplete = 100 - (($i/$seconds) * 100)
Write-Progress -SecondsRemaining $i `
-Activity "Timer" `
-Status "Time remaining:" `
-PercentComplete $percentComplete
Start-Sleep -Seconds 1
}
Show-Notification -Message "$Minutes minutes passed" -Title "Timer finished"
}