Skip to content

Instantly share code, notes, and snippets.

@alan-mushi
Created November 8, 2015 14:11
Show Gist options
  • Select an option

  • Save alan-mushi/0949f12fd82bb042a02d to your computer and use it in GitHub Desktop.

Select an option

Save alan-mushi/0949f12fd82bb042a02d to your computer and use it in GitHub Desktop.

Revisions

  1. alan-mushi created this gist Nov 8, 2015.
    21 changes: 21 additions & 0 deletions pulseaudio_toggle_mute.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/bin/bash

    # This simple helper script toggle the mute attribute for a program in pulseaudio.

    PROG="Chromium"

    all=$(pacmd list-sink-inputs | egrep -B 15 "client: [0-9]+ <${PROG}>" | sed -n '1p;8p')

    index=${all:11:2} # get the index
    muted=${all:22:3} # get 'yes' or 'no'

    echo "[~] Pulseaudio on ${PROG}:"
    echo -e "\tindex: ${index:-index not set}"
    echo -e "\tmuted: ${muted:-muted not set}"

    if [ "$muted" == "yes" ] ; then
    echo "[*] ${PROG} is detected as mute, let's change that"
    pacmd set-sink-input-mute $index false
    else
    echo "[-] ${PROG} not found or already unmuted"
    fi