Skip to content

Instantly share code, notes, and snippets.

@tytydraco
Created June 26, 2021 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tytydraco/7b174c752842b120b5697e0f90ddba88 to your computer and use it in GitHub Desktop.
Save tytydraco/7b174c752842b120b5697e0f90ddba88 to your computer and use it in GitHub Desktop.
Quick chrome audio control: "[" -15%; "]" +15%
#!/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