From fb9d9561f3cbbc2f0b97920a9df7892ed4086c83 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado <55825613+luevano@users.noreply.github.com> Date: Thu, 24 Dec 2020 14:46:01 -0700 Subject: Add script, (pulse audio) gets current sink, and changes to next, displaying notification --- .config/bspwm/bspwmrc | 3 +- .config/sxhkd/sxhkdrc | 3 ++ .local/bin/pa_control | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100755 .local/bin/pa_control diff --git a/.config/bspwm/bspwmrc b/.config/bspwm/bspwmrc index 7118942..a87445f 100755 --- a/.config/bspwm/bspwmrc +++ b/.config/bspwm/bspwmrc @@ -62,7 +62,8 @@ bspc config borderless_monocle true bspc config gapless_monocle true # Could try poniter_follows_monitor instead. -bspc config pointer_follows_focus true +# This fucks up when switching tags via polybar. +# bspc config pointer_follows_focus true # Colors. # First get all colors. diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index af7473c..044ce1d 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -153,10 +153,13 @@ super + {Left,Down,Up,Right} XF86AudioMute pactl set-sink-mute @DEFAULT_SINK@ toggle + F86AudioPrev playerctl previous + F86AudioNext playerctl next + F86AudioPlay playerctl play-pause diff --git a/.local/bin/pa_control b/.local/bin/pa_control new file mode 100755 index 0000000..d209374 --- /dev/null +++ b/.local/bin/pa_control @@ -0,0 +1,100 @@ +#!/bin/sh + +default_sink= +default_sink_nickname= + +get_default_sink (){ + default_sink="$(pactl info | grep Sink | awk '{print $3}')" +} + +get_default_sink_nickname (){ + sink_list="$(pactl list sinks\ + | grep -e Name -e alsa.card_name\ + | sed -e 's/^\ *//' -e 's/\ *$//')" + + found_default_sink="0" + + while IFS= read line; do + # Trim line depending on content. + if [ "$(echo $line | cut -d' ' -f1)" = "Name:" ]; then + line="$(echo $line | cut -d' ' -f2)" + else + line="$(echo $line | cut -d' ' -f3- | sed 's/\"//g')" + fi + + + # If fond default_sink, get and set the nickname, then exit. + if [ $found_default_sink = "1" ]; then + default_sink_nickname="$line" + break; + fi + + # If current line is the default sink, set a flag. + if [ $default_sink = "$line" ]; then + found_default_sink="1" + fi + done <