Fixed mic mute toggle button XF86AudioMicMute and added a notification when pressed

master
Meliurwen 3 years ago
parent a4a52aec27
commit 3aa60ab4d4
Signed by: meliurwen
GPG Key ID: 818A8B35E9F1CE10
  1. 6
      i3/.config/i3/config
  2. 60
      i3/.config/i3/scripts/volumeControl.sh
  3. BIN
      icons/.icons/Adwaita-dark-custom/32x32/status/microphone-sensitivity-high.png
  4. BIN
      icons/.icons/Adwaita-dark-custom/32x32/status/microphone-sensitivity-muted.png

@ -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" 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 # 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 XF86AudioRaiseVolume exec --no-startup-id ~/.config/i3/scripts/volumeControl.sh up
bindsym XF86AudioLowerVolume exec --no-startup-id ~/.config/i3/scripts/volumeControl.sh down 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 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 # Screen brightness controls
##bindsym XF86MonBrightnessUp exec "xbacklight -inc 10" ##bindsym XF86MonBrightnessUp exec "xbacklight -inc 10"

@ -4,6 +4,7 @@
# $ ./volumeControl.sh up # $ ./volumeControl.sh up
# $ ./volumeControl.sh down # $ ./volumeControl.sh down
# $ ./volumeControl.sh mute # $ ./volumeControl.sh mute
# $ ./volumeControl.sh mic
# Script modified from these wonderful people: # Script modified from these wonderful people:
# https://github.com/dastorm/volume-notification-dunst/blob/master/volume.sh # 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 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 { function draw_bar {
percentual=$1 percentual=$1
slices=$2 slices=$2
@ -34,32 +39,38 @@ function draw_bar {
} }
function send_notification { function send_notification {
if is_mute ; then if [ $1 == "audio" ] ; then
notif_icon="audio-volume-muted-dark" replace_id=2593
notif_text="Muted" if is_mute ; then
else notif_icon="audio-volume-muted-dark"
volume=$(get_volume) notif_text="Audio Muted"
if [ $volume -le 0 ] ; then
notif_icon="audio-volume-none-dark"
else 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" 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 else
if [ $volume -le 85 ] ; then notif_icon="audio-volume-overamplified-dark"
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
fi 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 fi
notif_text="$(draw_bar $volume 5)"
fi fi
# Send the notification # 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 case $1 in
@ -68,16 +79,21 @@ case $1 in
amixer -D pulse set Master on > /dev/null amixer -D pulse set Master on > /dev/null
# up the volume (+ 5%) # up the volume (+ 5%)
amixer -D pulse sset Master 5%+ > /dev/null amixer -D pulse sset Master 5%+ > /dev/null
send_notification send_notification audio
;; ;;
down) down)
amixer -D pulse set Master on > /dev/null amixer -D pulse set Master on > /dev/null
amixer -D pulse sset Master 5%- > /dev/null amixer -D pulse sset Master 5%- > /dev/null
send_notification send_notification audio
;; ;;
mute) mute)
# toggle mute # toggle mute
amixer -D pulse set Master 1+ toggle > /dev/null 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 esac

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 611 B

Loading…
Cancel
Save