From a031cd16363ef2c1b99e49e5313054778596d9ba Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 8 Aug 2019 16:45:42 -0500 Subject: [PATCH] Mic handling script with polybar integration --- apps/neovim/settings.vim | 2 ++ de/bar/mic.bash | 36 ++++++++++++++++++++++++++++++++++++ de/bar/polybar-config | 12 ++++++++++-- de/compton/compton.conf | 13 +++++-------- de/sxhkd/sxhkdrc | 3 +++ de/x/resources | 3 ++- shell/bash/bashrc | 2 ++ shell/tmux/tmux.conf | 2 +- 8 files changed, 61 insertions(+), 12 deletions(-) create mode 100755 de/bar/mic.bash diff --git a/apps/neovim/settings.vim b/apps/neovim/settings.vim index 03f07c2..9b9b4b2 100644 --- a/apps/neovim/settings.vim +++ b/apps/neovim/settings.vim @@ -154,3 +154,5 @@ hi Search cterm=NONE ctermbg=blue ctermfg=black highlight LineNr ctermbg=none ctermfg=8 highlight CursorLineNr ctermbg=18 ctermfg=gray hi IndentGuidesEven ctermbg=18 + +hi Normal ctermbg=NONE diff --git a/de/bar/mic.bash b/de/bar/mic.bash new file mode 100755 index 0000000..b51f5ef --- /dev/null +++ b/de/bar/mic.bash @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +pidfile="/var/run/user/$UID/polybar-mic-script.pid" + +if [ -e "$pidfile" ]; then + kill "$(cat "${pidfile}")" > /dev/null 2>&1 + cleanup +fi + +cleanup() { + rm -f "$pidfile" +} + +print_status() { + if amixer get Capture | grep -q '\[off\]'; then + echo "" + else + echo " " + fi +} + +toggle() { + amixer set Capture toggle > /dev/null 2>&1 + print_status +} + +trap "cleanup" EXIT +trap "toggle" USR1 + +echo $$ > "$pidfile" + +while true; do + print_status + sleep 1 & + wait +done diff --git a/de/bar/polybar-config b/de/bar/polybar-config index 5d79ada..d18e6b3 100644 --- a/de/bar/polybar-config +++ b/de/bar/polybar-config @@ -4,7 +4,7 @@ [colors] foreground = ${xrdb:color7:#222222} -background = ${xrdb:color0:#111111} +background = #bb111111 tray-bg = #222222 @@ -68,7 +68,7 @@ font-1 = ${env:BAR_ICON_FONT_DECLARATION} modules-left = bspwm modules-center = date -modules-right = cpu filesystem memory volume xbacklight xkeyboard temperature battery +modules-right = cpu filesystem memory volume microphone xbacklight xkeyboard temperature battery tray-position = right tray-padding = 0 @@ -385,3 +385,11 @@ compositing-border = source [global/wm] margin-top = ${env:WINDOW_GAP} margin-bottom = ${env:WINDOW_GAP} + +[module/microphone] +type = custom/script +exec = $DOTFILES_PATH/de/bar/mic.bash +tail = true +format =