From 8b176a2eb26be080489c8e31465cab1794fb5a65 Mon Sep 17 00:00:00 2001 From: James Brundage <@github.com> Date: Sun, 28 Jan 2024 10:13:53 -0800 Subject: [PATCH] feat: Set-Awtrix -PercentComplete/-Completed ( Fixes #114 ) --- Functions/Awtrix/Set-Awtrix.ps1 | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/Functions/Awtrix/Set-Awtrix.ps1 b/Functions/Awtrix/Set-Awtrix.ps1 index 436f70d..7a17f2d 100644 --- a/Functions/Awtrix/Set-Awtrix.ps1 +++ b/Functions/Awtrix/Set-Awtrix.ps1 @@ -97,9 +97,20 @@ function Set-Awtrix # One or more messages of notification text [Parameter(ValueFromPipelineByPropertyName)] + [Alias('Activity')] [string[]] $NotificationText, + # If provided, will display a progress bar within a notification. + [Parameter(ValueFromPipelineByPropertyName)] + [int] + $PercentComplete, + + # If set, will clear a progress bar within a notification. + [Parameter(ValueFromPipelineByPropertyName)] + [switch] + $Completed, + # The duration of the notification (rounded to the nearest second). # By default, 15 seconds. [Parameter(ValueFromPipelineByPropertyName)] @@ -296,15 +307,24 @@ function Set-Awtrix if ($EffectOption) { $invokeSplat.Body.effectSettings = $EffectOption - } - - if ($EffectSpeed) { + } else { if (-not $invokeSplat.Body.effectSettings) { $invokeSplat.Body.effectSettings = @{} } + } + + if ($EffectSpeed) { $invokeSplat.Body.effectSettings.speed = $EffectSpeed } + if ($Completed) { + $PSBoundParameters['PercentComplete'] = $PercentComplete = -1 + } + + if ($PSBoundParameters.ContainsKey('PercentComplete')) { + $invokeSplat.Body.progress = $PercentComplete + } + if ($HoldNotification) { $invokeSplat.Body.hold = $true } elseif ($PSBoundParameters["NotifcationDuration"]) {