From 3aa60ab4d488d28adee7a272d1f9d84c9fd311ee Mon Sep 17 00:00:00 2001 From: meliurwen Date: Wed, 15 Sep 2021 08:25:01 +0200 Subject: [PATCH] Fixed mic mute toggle button XF86AudioMicMute and added a notification when pressed --- i3/.config/i3/config | 6 +- i3/.config/i3/scripts/volumeControl.sh | 60 +++++++++++------- .../status/microphone-sensitivity-high.png | Bin 0 -> 438 bytes .../status/microphone-sensitivity-muted.png | Bin 0 -> 611 bytes 4 files changed, 39 insertions(+), 27 deletions(-) create mode 100644 icons/.icons/Adwaita-dark-custom/32x32/status/microphone-sensitivity-high.png create mode 100644 icons/.icons/Adwaita-dark-custom/32x32/status/microphone-sensitivity-muted.png diff --git a/i3/.config/i3/config b/i3/.config/i3/config index 9f46b47..8b50024 100644 --- a/i3/.config/i3/config +++ b/i3/.config/i3/config @@ -199,14 +199,10 @@ bindsym XF86ScreenSaver exec "dm-tool lock" bindsym Print --release exec "screenshot_image=$(date +%F_%T).png && deepin-screenshot --no-notification -s /tmp/$screenshot_image && xclip -selection c -t image/png < /tmp/$screenshot_image && rm /tmp/$screenshot_image && unset screenshot_image" # Speakers and Mic Controls -##bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +5% -##bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -5% -##bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 0 toggle -bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute 1 toggle - bindsym XF86AudioRaiseVolume exec --no-startup-id ~/.config/i3/scripts/volumeControl.sh up bindsym XF86AudioLowerVolume exec --no-startup-id ~/.config/i3/scripts/volumeControl.sh down bindsym XF86AudioMute exec --no-startup-id ~/.config/i3/scripts/volumeControl.sh mute +bindsym XF86AudioMicMute exec --no-startup-id ~/.config/i3/scripts/volumeControl.sh mic # Screen brightness controls ##bindsym XF86MonBrightnessUp exec "xbacklight -inc 10" diff --git a/i3/.config/i3/scripts/volumeControl.sh b/i3/.config/i3/scripts/volumeControl.sh index ee61a7e..f98ca2c 100755 --- a/i3/.config/i3/scripts/volumeControl.sh +++ b/i3/.config/i3/scripts/volumeControl.sh @@ -4,6 +4,7 @@ # $ ./volumeControl.sh up # $ ./volumeControl.sh down # $ ./volumeControl.sh mute +# $ ./volumeControl.sh mic # Script modified from these wonderful people: # https://github.com/dastorm/volume-notification-dunst/blob/master/volume.sh @@ -17,6 +18,10 @@ function is_mute { amixer get Master | grep '%' | grep -oE '[^ ]+$' | grep off > /dev/null } +function is_mic_mute { + amixer get Capture | grep '%' | grep -oE '[^ ]+$' | grep off > /dev/null +} + function draw_bar { percentual=$1 slices=$2 @@ -34,32 +39,38 @@ function draw_bar { } function send_notification { - if is_mute ; then - notif_icon="audio-volume-muted-dark" - notif_text="Muted" - else - volume=$(get_volume) - if [ $volume -le 0 ] ; then - notif_icon="audio-volume-none-dark" + if [ $1 == "audio" ] ; then + replace_id=2593 + if is_mute ; then + notif_icon="audio-volume-muted-dark" + notif_text="Audio Muted" else - if [ $volume -le 30 ] ; then + volume=$(get_volume) + if [ $volume -le 0 ] ; then + notif_icon="audio-volume-none-dark" + elif [ $volume -le 30 ] ; then notif_icon="audio-volume-low-dark" + elif [ $volume -le 85 ] ; then + notif_icon="audio-volume-medium-dark" + elif [ $volume -le 100 ] ; then + notif_icon="audio-volume-high-dark" else - if [ $volume -le 85 ] ; then - notif_icon="audio-volume-medium-dark" - else - if [ $volume -le 100 ] ; then - notif_icon="audio-volume-high-dark" - else - notif_icon="audio-volume-overamplified-dark" - fi - fi + notif_icon="audio-volume-overamplified-dark" fi + notif_text="$(draw_bar $volume 5)" + fi + else + replace_id=2594 + if is_mic_mute ; then + notif_icon="microphone-sensitivity-muted" + notif_text="Microphone Muted" + else + notif_icon="microphone-sensitivity-high" + notif_text="Microphone On" fi - notif_text="$(draw_bar $volume 5)" fi # Send the notification - dunstify -i $notif_icon -r 2593 -u normal "$notif_text" + dunstify -i $notif_icon -r $replace_id -u normal "$notif_text" } case $1 in @@ -68,16 +79,21 @@ case $1 in amixer -D pulse set Master on > /dev/null # up the volume (+ 5%) amixer -D pulse sset Master 5%+ > /dev/null - send_notification + send_notification audio ;; down) amixer -D pulse set Master on > /dev/null amixer -D pulse sset Master 5%- > /dev/null - send_notification + send_notification audio ;; mute) # toggle mute amixer -D pulse set Master 1+ toggle > /dev/null - send_notification + send_notification audio + ;; + mic) + # toggle microphone mute + amixer -D pulse set Capture toggle > /dev/null + send_notification mic ;; esac diff --git a/icons/.icons/Adwaita-dark-custom/32x32/status/microphone-sensitivity-high.png b/icons/.icons/Adwaita-dark-custom/32x32/status/microphone-sensitivity-high.png new file mode 100644 index 0000000000000000000000000000000000000000..4f6ec6f3b2e06a91444e501a7db50ccddd3a10a9 GIT binary patch literal 438 zcmV;n0ZIOeP) zy-EW?5XW~#ynxYE79nS!R}kYHh%cd4G>NZbDOd@41cM^B8f_wiXO-4IADx~*n=OXp z&YO)MvA91hEIT{1zx^I#JOxyM9`FdvT^RyhATUJ=*alw6)-w_xk1U8l8*flD^> zGy>Ly-?gx{wQ1LvX<=Sq+eI0gnO1787c^;PrDiu1DM gMRSMpJ6<}#H}w_!<^M5V$p8QV07*qoM6N<$f^sCY`2YX_ literal 0 HcmV?d00001 diff --git a/icons/.icons/Adwaita-dark-custom/32x32/status/microphone-sensitivity-muted.png b/icons/.icons/Adwaita-dark-custom/32x32/status/microphone-sensitivity-muted.png new file mode 100644 index 0000000000000000000000000000000000000000..fecdf86ebd4b5984b6ba53558ce2ab063553fa66 GIT binary patch literal 611 zcmV-p0-XJcP)IxR)FikdEf2>J)kRTSjC?z z25$oEK&!yyEAU#q>96wt(v)aS~c-mVf>{@PHO6nB=EGO%az>b%36J&KgBNiU9lw`kA2j6T4M2YkKfo$yu~rDDYkQ8h!`Px_-&mIODkx z>=uE01)1#y{o;sAx^fd907Y_eIw|f$5JvgTLA6`aNCj&OH#5UNw5By z6PnrWfV}S@PW`MFNNFo@!5*+T5mM?my#vgL)V;|-l$?I%>Hv5k>80=A2Ra#N&Ws0bhf(e`+qNLVz+$%^y6v`P1Y1K`+urRiVHvZU=C0NHF%^5xk`QYxuy zWM^002ovPDHLkV1i!Y9YFv9 literal 0 HcmV?d00001