Functions/LoupeDeck/Get-LoupeDeckProfile.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 |
function Get-LoupeDeckProfile { <# .SYNOPSIS Gets LoupeDeck Profiles .DESCRIPTION Gets Profiles for LoupeDeck .EXAMPLE Get-LoupeDeckProfile #> param( # The name of the profile [Parameter(ValueFromPipelineByPropertyName)] [string] $Name, # The profile root. # This will be automatically set if it is not provided. [Parameter(ValueFromPipelineByPropertyName)] [string[]] $ProfileRoot ) begin { filter ImportLoupeDeckProfile { [IO.File]::ReadAllText($_.FullName) | ConvertFrom-Json | & { process { if ($name -and $_.DisplayName -notlike $name) { return } $_.pstypenames.clear() $_.pstypenames.add('LoupeDeck.Profile') $_ } } } } process { if (-not $ProfileRoot) { $ProfileRoot = if ($IsWindows -or (-not $IsMacOS -and -not $IsLinux)) { $env:APPDATA | Split-Path | Join-Path -ChildPath Local | Join-Path -ChildPath Loupedeck | Join-Path -ChildPath Applications } elseif ($IsMacOS) { Join-Path "$env:HOME/.local/share/Loupedeck" "Applications" } } if (-not $ProfileRoot) { return } $ProfileRoot | Get-ChildItem | Get-ChildItem | Get-ChildItem -Filter Profiles | Get-ChildItem | Get-ChildItem -Filter ProfileInfo.json | ImportLoupeDeckProfile } } |