Skip to content

Instantly share code, notes, and snippets.

@alatalo
Last active June 23, 2024 10:05
Show Gist options
  • Save alatalo/8a2cb4124d69b50e6edeb70a6006feef to your computer and use it in GitHub Desktop.
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
#!/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
}
#!/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
@alatalo
Copy link
Author

alatalo commented Jun 23, 2024

Preview:
ArctisBatteryLevel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment