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 0000000..4f6ec6f Binary files /dev/null and b/icons/.icons/Adwaita-dark-custom/32x32/status/microphone-sensitivity-high.png differ 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 0000000..fecdf86 Binary files /dev/null and b/icons/.icons/Adwaita-dark-custom/32x32/status/microphone-sensitivity-muted.png differ