Procházet zdrojové kódy

Add subcommands for basic sound control

Alois Mahdal před 10 roky
rodič
revize
49d9d5e6ac
1 změnil soubory, kde provedl 35 přidání a 0 odebrání
  1. 35
    0
      bin/eeiam.in

+ 35
- 0
bin/eeiam.in Zobrazit soubor

@@ -17,7 +17,10 @@ available_commands() {
17 17
     echo at
18 18
     echo back
19 19
     echo bbl
20
+    echo deaf
21
+    echo deafnomore
20 22
     echo gone
23
+    echo listening
21 24
     echo moving
22 25
     echo ooo
23 26
     echo wfh
@@ -79,6 +82,21 @@ set_status() {
79 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 102
 # subcommand handlers
@@ -132,6 +150,14 @@ i_am_bbl() {
132 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 161
 i_am_gone() {
136 162
     #
137 163
     # gone fishin'
@@ -143,6 +169,15 @@ i_am_gone() {
143 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 181
 i_am_moving() {
147 182
     #
148 183
     # to other train or dreamland, but localhost must sleep now