Created
June 26, 2021 05:51
-
-
Save tytydraco/7b174c752842b120b5697e0f90ddba88 to your computer and use it in GitHub Desktop.
Quick chrome audio control: "[" -15%; "]" +15%
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 bash | |
xinput test-xi2 --root 3 | \ | |
gawk '/RawKeyRelease/ {getline; getline; print $2; fflush()}' | \ | |
while read -r key | |
do | |
[[ "$key" -ne 34 && "$key" -ne 35 ]] && continue | |
VOL="+15%" | |
[[ "$key" -eq 34 ]] && VOL="-15%" | |
echo "$VOL" | |
chrome_ids="$(pactl list short | grep chrome | awk '{print $1}')" | |
sinks="$(pactl list sink-inputs short)" | |
for id in $chrome_ids | |
do | |
chrome_id="$(echo "$sinks" | grep "$id" | awk '{print $1}')" | |
[[ -z "$chrome_id" ]] && continue | |
pactl set-sink-input-volume "$chrome_id" "$VOL" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment