Browse Source

Add subcommands for basic sound control

Alois Mahdal 10 years ago
parent
commit
49d9d5e6ac
1 changed files with 35 additions and 0 deletions
  1. 35
    0
      bin/eeiam.in

+ 35
- 0
bin/eeiam.in View File

17
     echo at
17
     echo at
18
     echo back
18
     echo back
19
     echo bbl
19
     echo bbl
20
+    echo deaf
21
+    echo deafnomore
20
     echo gone
22
     echo gone
23
+    echo listening
21
     echo moving
24
     echo moving
22
     echo ooo
25
     echo ooo
23
     echo wfh
26
     echo wfh
79
     iniread -p iam.saying.like.this.$what | bash
82
     iniread -p iam.saying.like.this.$what | bash
80
 }
83
 }
81
 
84
 
85
+sound_is_muted() {
86
+    #
87
+    # At least one playback channel is muted
88
+    #
89
+    local master_status="$(amixer get Master)"
90
+    echo "$master_status" \
91
+      | grep "Playback channels" \
92
+      | sed -e 's/.*: //; s/ - /\n/' \
93
+      | while read chname
94
+        do
95
+            grep -e "^ *$chname" <<<"$master_status"
96
+        done \
97
+      | grep -qse '\[off\]$'
98
+}
99
+
82
 
100
 
83
 #
101
 #
84
 # subcommand handlers
102
 # subcommand handlers
132
     setxkbmap "$nxt"
150
     setxkbmap "$nxt"
133
 }
151
 }
134
 
152
 
153
+i_am_deaf() {
154
+    amixer -q sset Master 5%+
155
+}
156
+
157
+i_am_deafnomore() {
158
+    amixer -q sset Master 5%-
159
+}
160
+
135
 i_am_gone() {
161
 i_am_gone() {
136
     #
162
     #
137
     # gone fishin'
163
     # gone fishin'
143
     i_am_back
169
     i_am_back
144
 }
170
 }
145
 
171
 
172
+i_am_listening() {
173
+    if sound_is_muted;
174
+    then
175
+        amixer -q sset Master unmute;
176
+    else
177
+        amixer -q sset Master mute;
178
+    fi
179
+}
180
+
146
 i_am_moving() {
181
 i_am_moving() {
147
     #
182
     #
148
     # to other train or dreamland, but localhost must sleep now
183
     # to other train or dreamland, but localhost must sleep now