diff --git a/bin/mic-toggle.sh b/bin/mic-toggle.sh new file mode 100755 index 0000000..b05d987 --- /dev/null +++ b/bin/mic-toggle.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +CARD='C920' + +declare -A ICONS=([on]=microphone-sensitivity-high [off]=microphone-sensitivity-muted) + +# Toggle the mic +amixer -c ${CARD} sset Mic mute toggle + +# Grab the state +STATE=$(amixer -c ${CARD} cget name='Mic Capture Switch' | grep -F ': values=' | cut -f2 -d=) + +# Notify +notify-send -t 3000 "${CARD} Mic" ${STATE^^} -i ${ICONS[${STATE}]} diff --git a/bin/mute b/bin/mute index 019be0b..798ae3b 100755 --- a/bin/mute +++ b/bin/mute @@ -3,4 +3,6 @@ case $(uname -s) in Darwin) osascript -e "set volume output volume 0" ;; + Linux) pactl set-sink-mute @DEFAULT_SINK@ on + ;; esac diff --git a/bin/mutelock.sh b/bin/mutelock.sh new file mode 100755 index 0000000..52a18d6 --- /dev/null +++ b/bin/mutelock.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Credit for code: + #https://unix.stackexchange.com/users/14353/cliff-stanford + #https://unix.stackexchange.com/users/231160/nik-gnomic +# Post on stackexchange: https://unix.stackexchange.com/questions/467456/how-to-mute-sound-when-xscreensaver-locks-screen/589614#589614 + +gdbus monitor -e -d org.xfce.ScreenSaver | grep ActiveChanged --line-buffered | + while read line + do + case "$line" in + *"(true,)"*) + pactl set-sink-mute @DEFAULT_SINK@ on + ;; + *"(false,)"*) + pactl set-sink-mute @DEFAULT_SINK@ off + ;; + esac + done +exit