Skip to content

Commit

Permalink
feat: Set-Awtrix -PercentComplete/-Completed ( Fixes #114 )
Browse files Browse the repository at this point in the history
  • Loading branch information
James Brundage committed Jan 28, 2024
1 parent 55bdf6f commit 8b176a2
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions Functions/Awtrix/Set-Awtrix.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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"]) {
Expand Down

0 comments on commit 8b176a2

Please sign in to comment.