Add some useful scripts re: audio muting
This commit is contained in:
parent
ddfeace631
commit
d0e5e2a23e
14
bin/mic-toggle.sh
Executable file
14
bin/mic-toggle.sh
Executable file
|
@ -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}]}
|
2
bin/mute
2
bin/mute
|
@ -3,4 +3,6 @@
|
||||||
case $(uname -s) in
|
case $(uname -s) in
|
||||||
Darwin) osascript -e "set volume output volume 0"
|
Darwin) osascript -e "set volume output volume 0"
|
||||||
;;
|
;;
|
||||||
|
Linux) pactl set-sink-mute @DEFAULT_SINK@ on
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
19
bin/mutelock.sh
Executable file
19
bin/mutelock.sh
Executable file
|
@ -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
|
Loading…
Reference in a new issue