Last active
June 23, 2024 10:05
-
-
Save alatalo/8a2cb4124d69b50e6edeb70a6006feef to your computer and use it in GitHub Desktop.
Show the battery level of Logitech Arctis 7 headset in small Powershell window. Uses HeadsetControl by Sapd <Denis Arnst> at https://github.com/Sapd/HeadsetControl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env pwsh | |
# Show the battery level of Logitech Arctis 7 headset in a | |
# small Powershell window. Uses HeadsetControl by Sapd <Denis Arnst>. | |
# | |
# Requirements: | |
# * Powershell and `Set-ExecutionPolicy RemoteSigned` | |
# * headsetcontrol.exe https://github.com/Sapd/HeadsetControl | |
# | |
# Note: For desktop icon, see attached headset_createDesktopIcon.ps1 | |
# | |
# -- by alatalo <https://github.com/alatalo> 06/2024 | |
$width = 36 | |
$height = 4 | |
$sleep = 10 | |
$command = { | |
.\headsetcontrol.exe -b | |
} | |
[System.Console]::WindowWidth = $width | |
[System.Console]::WindowHeight = $height | |
[System.Console]::BufferWidth = $width | |
[System.Console]::BufferHeight = $height | |
while ($true) { | |
Clear-Host | |
Write-Output "`n" | |
Get-Date -Format "yyyy-MM-dd HH:mm:ss" | |
$output = & $command | |
$level = $output | Select-String -Pattern "Level:" | |
$level.Line.Trim() | |
Start-Sleep -Seconds $sleep | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env pwsh | |
# Create a desktop icon shortcut for a Powershell script. | |
# | |
# Requirements: | |
# * Powershell | |
# | |
# -- by alatalo <https://github.com/alatalo> 06/2024 | |
# Path to script | |
$targetPath = "C:\path\to\GetArctisBatteryLevel.ps1" | |
# Path to the Desktop icon and name of the Shortcut | |
$shortcutPath = [System.IO.Path]::Combine([System.Environment]::GetFolderPath('Desktop'), 'Arctis Battery Level.lnk') | |
# Create shortcut | |
$wshShell = New-Object -ComObject WScript.Shell | |
$shortcut = $wshShell.CreateShortcut($shortcutPath) | |
$shortcut.TargetPath = "powershell.exe" | |
$shortcut.Arguments = "-NoLogo -NoProfile -File `"$targetPath`"" | |
$shortcut.WorkingDirectory = [System.IO.Path]::GetDirectoryName($targetPath) | |
$shortcut.WindowStyle = 1 | |
$shortcut.IconLocation = "powershell.exe, 0" | |
$shortcut.Save() | |
Write-Output "Shortcut created on the Desktop successfully. Exiting in 5 seconds.." | |
Start-Sleep -Seconds 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Preview:
