I am working on a PowerShell script
that creates a Fedora WSL using docker, it all works, but I cannot get to work the code part which sets the icon in the settings.json
file.
Relevant part of the JSON:
"profiles":
{
"defaults": {},
"list":
[
{
"commandline": "PATH\\TO\\WSL",
"guid": "{your-guid}",
"hidden": false,
"name": "fedora",
"icon": "PATH\\TO\\ICON"
},
{
"commandline": "cmd.exe",
"guid": "{your-guid}}",
"hidden": false,
"name": "Command Prompt"
},
{
"guid": "{your-guid}}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
},
Here is what I've tryied:
$settings = Get-Content $env:localappdata'\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json' -raw | ConvertFrom-Json
$settings.profiles.list | % {if($_.name -eq $WSLname){$_.icon=$InstallPath\fedora.ico}}
$settings | ConvertTo-Json -depth 32| set-content $env:localappdata'\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json'
Variables are taken from params in first part of the script.
My goal is to chech if the profile name with given input by the user exists, if so, changes or adds the "icon" property to the fedora.ico path.
Edit: This part of the script needs to run after windows terminal has been relaunched.