瀏覽代碼

Move volume control to separate subcommand

Alois Mahdal 10 年之前
父節點
當前提交
6a6a9770d5
共有 3 個檔案被更改,包括 91 行新增44 行删除
  1. 1
    0
      mkit/config.ini
  2. 90
    0
      src/libexec/saturnin-au
  3. 0
    44
      src/libexec/saturnin-iam

+ 1
- 0
mkit/config.ini 查看文件

@@ -41,6 +41,7 @@
41 41
     src/bin/saturnin                        = saturnin
42 42
 
43 43
 [files:libexec]
44
+    src/libexec/saturnin-au                 = saturnin-au
44 45
     src/libexec/saturnin-czrates            = saturnin-czrates
45 46
     src/libexec/saturnin-clip               = saturnin-clip
46 47
     src/libexec/saturnin-dmenu              = saturnin-dmenu

+ 90
- 0
src/libexec/saturnin-au 查看文件

@@ -0,0 +1,90 @@
1
+#!/bin/bash
2
+
3
+. $(ffoom path)
4
+
5
+ffoo import pretty
6
+
7
+
8
+usage() {
9
+    usage_is "up"     \
10
+             "down"   \
11
+             "flip"   \
12
+             "mute"   \
13
+             "unmute"
14
+}
15
+
16
+
17
+sound_is_muted() {
18
+    #
19
+    # At least one playback channel is muted
20
+    #
21
+    local master_status="$(amixer get Master)"
22
+    echo "$master_status" \
23
+      | grep "Playback channels" \
24
+      | sed -e 's/.*: //; s/ - /\n/' \
25
+      | while read chname
26
+        do
27
+            grep -e "^ *$chname" <<<"$master_status"
28
+        done \
29
+      | grep -qse '\[off\]$'
30
+}
31
+
32
+do_down() {
33
+    #
34
+    # turn volume down
35
+    #
36
+    amixer -q sset Master 5%-
37
+}
38
+
39
+do_flip() {
40
+    #
41
+    # mute or unmute
42
+    #
43
+    if sound_is_muted;
44
+    then
45
+        amixer -q sset Master unmute;
46
+    else
47
+        amixer -q sset Master mute;
48
+    fi
49
+}
50
+
51
+do_mute() {
52
+    #
53
+    # mute
54
+    #
55
+    amixer -q sset Master mute
56
+}
57
+
58
+do_up() {
59
+    #
60
+    # turn volume up
61
+    #
62
+    amixer -q sset Master 5%+
63
+}
64
+
65
+do_unmute() {
66
+    #
67
+    # mute
68
+    #
69
+    amixer -q sset Master unmute
70
+}
71
+
72
+
73
+action=
74
+while true; do case "$1" in
75
+    up)     action=up;     shift ;;
76
+    down)   action=down;   shift ;;
77
+    flip)   action=flip;   shift ;;
78
+    mute)   action=mute;   shift ;;
79
+    unmute) action=unmute; shift ;;
80
+    "")     break                ;;
81
+    *)      usage                ;;
82
+esac done
83
+
84
+debug "\$@='$@'"
85
+debug -v action
86
+
87
+case $action in
88
+    up|down|flip|mute|unmute) do_$action ;;
89
+    *)                        usage      ;;
90
+esac

+ 0
- 44
src/libexec/saturnin-iam 查看文件

@@ -18,10 +18,7 @@ available_commands() {
18 18
     echo back
19 19
     echo bbl
20 20
     echo bbldone
21
-    echo deaf
22
-    echo deafnomore
23 21
     echo gone
24
-    echo listening
25 22
     echo ooo
26 23
     echo wfh
27 24
     echo writing
@@ -60,21 +57,6 @@ set_status() {
60 57
     saturnin conf -p iam.saying.like.this.$what | bash
61 58
 }
62 59
 
63
-sound_is_muted() {
64
-    #
65
-    # At least one playback channel is muted
66
-    #
67
-    local master_status="$(amixer get Master)"
68
-    echo "$master_status" \
69
-      | grep "Playback channels" \
70
-      | sed -e 's/.*: //; s/ - /\n/' \
71
-      | while read chname
72
-        do
73
-            grep -e "^ *$chname" <<<"$master_status"
74
-        done \
75
-      | grep -qse '\[off\]$'
76
-}
77
-
78 60
 
79 61
 #
80 62
 # hooks
@@ -146,20 +128,6 @@ i_am_bbldone() {
146 128
     setxkbmap "$(saturnin conf -1 -p iam.typing.lang)"
147 129
 }
148 130
 
149
-i_am_deaf() {
150
-    #
151
-    # so turn volume up
152
-    #
153
-    amixer -q sset Master 5%+
154
-}
155
-
156
-i_am_deafnomore() {
157
-    #
158
-    # so turn volume back down
159
-    #
160
-    amixer -q sset Master 5%-
161
-}
162
-
163 131
 i_am_gone() {
164 132
     #
165 133
     # gone fishin'
@@ -171,18 +139,6 @@ i_am_gone() {
171 139
     i_am_back
172 140
 }
173 141
 
174
-i_am_listening() {
175
-    #
176
-    # to the real world or to the box
177
-    #
178
-    if sound_is_muted;
179
-    then
180
-        amixer -q sset Master unmute;
181
-    else
182
-        amixer -q sset Master mute;
183
-    fi
184
-}
185
-
186 142
 i_am_ooo() {
187 143
     #
188 144
     # too dangerous to implement