summaryrefslogtreecommitdiffstats
path: root/oss_mute.sh
blob: a07a5526020f228b0ad01de85735859766f5852b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/dash
#----------------------------------------------------
# Version:      0.2.0
# Author:       Florian "Bluewind" Pritz <flo@xssn.at>
#
# Licensed under WTFPL v2
#   (see COPYING for full license text)
#    
#----------------------------------------------------
# script to (un)mute oss devices
#----------------------------------------------------
MODE="$1"
CONTROL="$2"

if [ $MODE = 1 ]; then
  MUTE=$(ossmix | grep "^$CONTROL\ " | awk '{print $4}' | awk -F')' '{print $1}')
  if [ "$MUTE" = 'ON' ]; then
	  ossmix "$CONTROL" OFF
  else
    ossmix "$CONTROL" ON
  fi
elif [ $MODE = 2 ]; then
 VOLUME=$(cat $HOME/.volume)
 if [ -z "$VOLUME" ]; then
       VOLUME=$(ossmix | grep "^$CONTROL " | awk '{print $4}' | awk -F : '{print $1}')
       ossmix $CONTROL 0
       echo $VOLUME > $HOME/.volume
 else
       ossmix $CONTROL $VOLUME 
       echo "" > $HOME/.volume
 fi
fi