Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JPersson77 committed Sep 30, 2023
2 parents 2d76cd7 + c2f70aa commit 8307325
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 0 deletions.
45 changes: 45 additions & 0 deletions Docs/Example scripts/Microsoft.PowerShell_profile.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function getBacklight()
{
$value = & 'C:\Program Files\LGTV Companion\LGTVcli.exe' -ok backlight -get_system_settings picture [`\`"backlight`\`"]
Write-Host "Backlight is set to $value"
}

function setBacklight([int]$value)
{
& 'C:\Program Files\LGTV Companion\LGTVcli.exe' -backlight "$value" | Out-Null
Write-Host "Backlight set to $value"
}

function volumeUp()
{
& 'C:\Program Files\LGTV Companion\LGTVcli.exe' -request com.webos.service.audio/master/volumeUp | Out-Null
}

function volumeDown()
{
& 'C:\Program Files\LGTV Companion\LGTVcli.exe' -request com.webos.service.audio/master/volumeDown | Out-Null
}


function getVolume()
{
$jsonObject = (& 'C:\Program Files\LGTV Companion\LGTVcli.exe' -request com.webos.service.audio/master/getVolume)|ConvertFrom-json
$volume=$jsonObject.Device1.payload.volumeStatus.volume
Write-Host "Volume is set to $volume"
}

function setVolume([int]$value)
{
& 'C:\Program Files\LGTV Companion\LGTVcli.exe' -request_with_param com.webos.service.audio/master/setVolume "{\`"volume\`":$value}" | Out-Null
Write-Host "Volume set to $value"
}

function setHDMI([int]$value)
{
if ($value -In 1..4) {
& 'C:\Program Files\LGTV Companion\LGTVcli.exe' -setHdmi "$value" | Out-Null
Write-Host "HDMI is set to $value"
} else {
Write-Host "HDMI can only be set between 1-4!"
}
}
63 changes: 63 additions & 0 deletions Docs/Powershell functions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Powershell example functions

Following functions are definedin the file [Microsoft.PowerShell_profile.ps1](./Example%20scripts/Microsoft.PowerShell_profile.ps1)

- getBacklight
- setBacklight [0-100]
- getVolume
- setVolume [0-100]
- volumeUp
- volumeDown
- setHDMI [1-4]

If you don't have this file already, just make a folder called `WindowsPowerShell` in your `C:\Users\<username>\Documents` and copy the file [Microsoft.PowerShell_profile.ps1](./Example%20scripts/Microsoft.PowerShell_profile.ps1) into it. The functions will be then usable in the every new powershell session.

# Functions

```Powershell
function getBacklight()
{
$value = & 'C:\Program Files\LGTV Companion\LGTVcli.exe' -ok backlight -get_system_settings picture [`\`"backlight`\`"]
Write-Host "Backlight is set to $value"
}
function setBacklight([int]$value)
{
& 'C:\Program Files\LGTV Companion\LGTVcli.exe' -backlight "$value" | Out-Null
Write-Host "Backlight set to $value"
}
function volumeUp()
{
& 'C:\Program Files\LGTV Companion\LGTVcli.exe' -request com.webos.service.audio/master/volumeUp | Out-Null
}
function volumeDown()
{
& 'C:\Program Files\LGTV Companion\LGTVcli.exe' -request com.webos.service.audio/master/volumeDown | Out-Null
}
function getVolume()
{
$jsonObject = (& 'C:\Program Files\LGTV Companion\LGTVcli.exe' -request com.webos.service.audio/master/getVolume)|ConvertFrom-json
$volume=$jsonObject.Device1.payload.volumeStatus.volume
Write-Host "Volume is set to $volume"
}
function setVolume([int]$value)
{
& 'C:\Program Files\LGTV Companion\LGTVcli.exe' -request_with_param com.webos.service.audio/master/setVolume "{\`"volume\`":$value}" | Out-Null
Write-Host "Volume set to $value"
}
function setHDMI([int]$value)
{
if ($value -In 1..4) {
& 'C:\Program Files\LGTV Companion\LGTVcli.exe' -setHdmi "$value" | Out-Null
Write-Host "HDMI is set to $value"
} else {
Write-Host "HDMI can only be set between 1-4!"
}
}
```

0 comments on commit 8307325

Please sign in to comment.