mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-08 09:04:18 +01:00
22 lines
511 B
PowerShell
Executable File
22 lines
511 B
PowerShell
Executable File
#!/snap/bin/powershell
|
|
|
|
# Syntax: ./turn-volume-down.ps1 [<percent>]
|
|
# Description: turns the audio volume down (-10% by default)
|
|
# Author: Markus Fleschutz
|
|
# Source: github.com/fleschutz/PowerShell
|
|
# License: CC0
|
|
|
|
Param([Int]$Percent = 10)
|
|
|
|
try {
|
|
$obj = New-Object -com wscript.shell
|
|
for ($i = 0; $i -lt $Percent; $i += 2) {
|
|
$obj.SendKeys([char]174) # each tick is -2%
|
|
}
|
|
write-output "OK"
|
|
exit 0
|
|
} catch {
|
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
exit 1
|
|
}
|