2

As you can tell by the name, I am an extra paranoid Panda and in order to keep my bamboo safe I don't want my input volume to be on just in case if I get some spyware which listens to my sound input. Basically I just want to be as safe as possible so that no other Panda listens in on my Panda bamboo secrets (where I put it all).

So basically this is what I want, a script which:

  • Checks whether or not the input volume for my microphone (or any sound input devices) is on 0% at regular intervals

  • Alerts me via notify-send every 5 minutes if it is on

  • An option within the script (like a boolean or something) which is not on by default, but if it is turned on will make it so that when the input volume is on I will be alerted that it was on and has been turned off, and for the script obviously also (probably before alerting me) to turn the input volume off

  • Is able to scan multiple input sources so that for instance if I have 2 microphones, 1 is muted, but the other not, it does not just assume that all is well

I am running Ubuntu GNOME 15.10 with GNOME 3.18. How can this be done? I don't expect there to be one (that's why I'm asking for a script), but if there is an application which can do this, then please recommend it.

2
  • If I can find a reliable way to get the input volume of all input devices, the rest is easy :) Jan 11, 2016 at 22:06
  • @JacobVlijm: You could do some clever grepping with the output of pactl list sources.
    – user364819
    Jan 15, 2016 at 13:53

1 Answer 1

3

Here is a simple script that scans a given pulseaudio input source for being muted*.

The source can be given as pulseaudio source index number as can be listed with:

pactl list sources

If the source was not muted a warning message will be displayed in a desktop notification.

#!/bin/bash
#
# Forces a pulseaudio source to be muted
#
# Usage:
# micmute <source> <wait> <--force>
# <source>: pulseaudio source index number
# <wait>: seconds to wait for checking
# <--force>: force muting microphone and notify
source="$1"
wait="$2"
force="$3"

echo "Scanning input #$source every $wait seconds."

while true; do
    if ! (pactl list sources | sed -n '/^Source #'"$source"'/,/^$/p' | grep "Mute: yes"); then
        if [[ $force == "--force" ]]; then
            pactl set-source-mute $source 1
            notify-send "Muting input $source"
        else
            notify-send "WARNING - input $source is not muted"
        fi
    fi
    sleep $wait  ## CLI option seconds to wait
done

Save that script with any name (e.g. micmute) and give it executable permission. The script then may be called with

./micmute <source> <wait> [--force]

<source> is the index number of the microphone source to be scanned.
<wait> will define the time in seconds after which we repeat our query for a muted source device.
--force is an optional flag to force muting of our source.


For me the following example line will query the mute state of my microphone (index 2) every 5 minutes, and it will forcedly mute it if it was unmuted.

./micmute 2 300 --force

* I preferred muting over setting the volume to 0 because of the advantage to restore the previous volume settings on unmuting.

3
  • So if I had two microphones, one muted, and the other not, would it just assume that all was well?
    – user364819
    Jan 16, 2016 at 18:05
  • It's a good answer you have posted, however I am sorry but as it doesn't fully match my specifications I cannot accept it in its current state, though I have given it an upvote.
    – user364819
    Jan 16, 2016 at 22:16
  • @ParanoidPanda: see edit for a script that queries a given source only. To listen to two or more sources at the same time run it multiple times with different parameters.
    – Takkat
    Jan 17, 2016 at 16:32

You must log in to answer this question.