From 6d129c015fee81fa2fc078d1aa6ddcd3246a0781 Mon Sep 17 00:00:00 2001 From: Taylan Date: Tue, 11 Jul 2023 23:11:50 +0300 Subject: [PATCH 1/2] powershell functions --- .../Microsoft.PowerShell_profile.ps1 | 35 +++++++++++++ Docs/Powershell functions.md | 52 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 Docs/Example scripts/Microsoft.PowerShell_profile.ps1 create mode 100644 Docs/Powershell functions.md diff --git a/Docs/Example scripts/Microsoft.PowerShell_profile.ps1 b/Docs/Example scripts/Microsoft.PowerShell_profile.ps1 new file mode 100644 index 0000000..f929135 --- /dev/null +++ b/Docs/Example scripts/Microsoft.PowerShell_profile.ps1 @@ -0,0 +1,35 @@ +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" +} diff --git a/Docs/Powershell functions.md b/Docs/Powershell functions.md new file mode 100644 index 0000000..20ed7cf --- /dev/null +++ b/Docs/Powershell functions.md @@ -0,0 +1,52 @@ +# 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 + +If you don't have this file already, just make a folder called `WindowsPowerShell` in your `C:\Users\\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" +} +``` \ No newline at end of file From dfdc3851ef880237b0ec7f38a2183001d8b478ff Mon Sep 17 00:00:00 2001 From: Taylan Date: Tue, 11 Jul 2023 23:53:10 +0300 Subject: [PATCH 2/2] setHDMI --- Docs/Example scripts/Microsoft.PowerShell_profile.ps1 | 10 ++++++++++ Docs/Powershell functions.md | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/Docs/Example scripts/Microsoft.PowerShell_profile.ps1 b/Docs/Example scripts/Microsoft.PowerShell_profile.ps1 index f929135..7a27c2d 100644 --- a/Docs/Example scripts/Microsoft.PowerShell_profile.ps1 +++ b/Docs/Example scripts/Microsoft.PowerShell_profile.ps1 @@ -33,3 +33,13 @@ 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!" + } +} diff --git a/Docs/Powershell functions.md b/Docs/Powershell functions.md index 20ed7cf..b895364 100644 --- a/Docs/Powershell functions.md +++ b/Docs/Powershell functions.md @@ -8,6 +8,7 @@ Following functions are definedin the file [Microsoft.PowerShell_profile.ps1](./ - 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\\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. @@ -49,4 +50,14 @@ 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!" + } +} ``` \ No newline at end of file