You are not logged in.

#1 2015-12-12 07:34:19

oremora
Member
Registered: 2015-12-11
Posts: 5

Pactl automatically change sinks

What I am trying to do is to automatically change the binded sink in pactl when listening to audio with bluetooth headphones. I am able to change the volume being outputted to my earphones by using pavucontrol, but when I try to change the volume with my keyboard it shows that I am changing the volume of my speakers. When I run

pactl list sinks

it shows that I have two sinks: 0 and 1. I can manually change the sink used by pactl in i3 to my headphones, but it will become a pain having to do that manually every time I want to use my keyboard to change volume, so I was wondering if there was an easier way that would allow pactl to switch to the sink being used.
This is my ~/.config/i3/config file section:

# Multimedia Keys
# increase volume
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume 0 +5%
# decrease volume
bindsym XF86AudioLowerVolume exec pactl set-sink-volume 0 -5%
# mute volume
bindsym XF86AudioMute exec pactl set-sink-mute 0 toggle

Any help is appreciated.

Offline

#2 2015-12-12 08:54:41

bibek22
Member
From: Nepal
Registered: 2015-09-10
Posts: 90

Re: Pactl automatically change sinks

I manipulated the fact that pactl lists the sinks in order they are connected. So, I wrote a script that basically greps the output of `pactl list sinks` and does `pactl set-sink-volume N +5%` only that N is replaced with the interface that is listed last. That does what I want.

Maybe there's a better way to do it. But, I really liked it when I was able to put together a bash script to solve something that I needed to do.

Offline

Board footer

Powered by FluxBB