Add loopback module

This commit is contained in:
Thomas Dehaeze 2020-04-30 21:57:54 +02:00
parent c380a48df9
commit bbf6878ffa

View File

@ -80,7 +80,7 @@
modules-left = i3 bspwm xwindow
modules-center =
modules-right = pulseaudio wired-network wireless-network wireguard nordvpn redshift lockscreen dunst packages unread_news unread_mail temperature battery date
modules-right = pulseaudio wired-network wireless-network wireguard nordvpn loopback redshift lockscreen dunst packages unread_news unread_mail temperature battery date
wm-restack = i3
@ -795,6 +795,56 @@
fi
#+end_src
* Microphone loopback
#+BEGIN_SRC conf
[module/loopback]
type = custom/script
format-underline = ${colors.bg}
click-left = ~/.config/polybar/scripts/loopback-toggle.sh >/dev/null 2>%1 &
format = <label>
exec = ~/.config/polybar/scripts/loopback-status.sh
interval = 2
#+END_SRC
** Loopback Status
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/loopback-status.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
loopback=$(pactl list 2>/dev/null | grep module-loopback | wc -l)
if [ $loopback -eq 0 ]; then
echo ""
else
echo "%{F#859900}%{F-}"
fi
#+end_src
** Toggle Loopback
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/loopback-toggle.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
loopback=$(pactl list 2>/dev/null | grep module-loopback | wc -l)
if [ $loopback -eq 0 ]; then
pactl load-module module-loopback latency_msec=1 && \
dunstify --replace=82244 "Loopback" "Enabled"
else
pactl unload-module module-loopback && \
dunstify --replace=82244 "Loopback" "Disabled"
fi
#+end_src
* Screenshot
#+BEGIN_SRC conf