From e8dfc6a726fbc6e074a9e074af38ce6f7773b6e5 Mon Sep 17 00:00:00 2001 From: Mikaela Suomalainen Date: Tue, 5 Feb 2019 00:09:46 +0200 Subject: [PATCH] i3: get the current pulseaudio sink before adjusting volume Adjusted from Jens Erat from https://faq.i3wm.org/question/125/how-to-change-the-systems-volume.1.html According to a comment this only works when something is playing, but I think that is the only case when I need volume keys and is improvement over it stopping working with volume devices changing. The proposed cutting running again resulted to three devices being listed and thus doesn't work. I also have the volumeicon which I can use to adjust volume if I really need to while there is nothing playing. --- conf/i3/config | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/conf/i3/config b/conf/i3/config index 00b826d3..acefa01d 100644 --- a/conf/i3/config +++ b/conf/i3/config @@ -175,14 +175,17 @@ bindsym $mod+Escape exec "i3lock; sudo /usr/sbin/hibernate" # Microsoft Wired Keyboard 600 bindsym XF86AudioPlay exec --no-startup-id playerctl play-pause -bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -5% -bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +5% -bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 0 toggle # mute sound #bindsym XF86Search # unknown key here looking like a share button? XF86Community ? #bindsym XF86Display # unknown key, likely XF86BrightnessAdjust as it's a sun, but could be XF86ContrastAdjust bindsym XF86Calculator exec --no-startup-id galculator +# Volume keys NOTE: won't work if nothing is playing (which I consider an improvement +# over randomly stopping working as I enable and disable audio devices). +set $sink $(pactl list short sinks | grep RUNNING | cut -f1) +bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume $sink -5% +bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume $sink +5% +bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute $sink toggle # mute sound # Float these apps by default for_window [title="^Mozilla Firefox$"] floating enable