aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rwxr-xr-xgenerate.sh23
-rw-r--r--main.go (renamed from cmd/horn/horn.go)8
-rw-r--r--sound.wav (renamed from cmd/horn/horn.wav)bin370212 -> 370212 bytes
4 files changed, 11 insertions, 22 deletions
diff --git a/README.md b/README.md
index c372fad..f3482bc 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@ Command-line air horn.
## Installation
~~~ sh
-$ go get github.com/kevinwallace/horn/cmd/horn
+$ go get -u doof.net/cmd/horn
~~~
## Usage
diff --git a/generate.sh b/generate.sh
index 7c431ec..50a0e3a 100755
--- a/generate.sh
+++ b/generate.sh
@@ -1,16 +1,5 @@
#!/bin/sh
-if [ $# != 1 ]; then
- echo >&2 "usage: $(basename "$0") <filename.wav>"
- exit 1
-fi
-
-filename="$1"
-name="$(basename -s .wav "${filename}")"
-root="$(dirname "$0")"
-
-mkdir -p "${root}/cmd/${name}"
-cp "${filename}" "${root}/cmd/${name}/${name}.wav"
-gofmt > "${root}/cmd/${name}/${name}.go" << EOF
+gofmt > main.go << EOF
package main
import (
@@ -19,14 +8,14 @@ import (
"os/exec"
)
-//go:generate ../../generate.sh ${name}.wav
+//go:generate generate.sh
func main() {
- f, err := ioutil.TempFile(os.TempDir(), "${name}")
+ f, err := ioutil.TempFile(os.TempDir(), os.Args[0])
if err != nil {
panic(err)
}
defer os.Remove(f.Name())
- if _, err := f.Write(${name}); err != nil {
+ if _, err := f.Write(sound); err != nil {
panic(err)
}
cmd := exec.Command("afplay", f.Name())
@@ -37,7 +26,7 @@ func main() {
}
}
-var ${name} = []byte{
- $(xxd -i < "${filename}" | sed 's/\([^,]\)$/\1,/')
+var sound = []byte{
+ $(xxd -i < sound.wav | sed 's/\([^,]\)$/\1,/')
}
EOF \ No newline at end of file
diff --git a/cmd/horn/horn.go b/main.go
index cd71f5e..6337094 100644
--- a/cmd/horn/horn.go
+++ b/main.go
@@ -6,14 +6,14 @@ import (
"os/exec"
)
-//go:generate ../../generate.sh horn.wav
+//go:generate generate.sh
func main() {
- f, err := ioutil.TempFile(os.TempDir(), "horn")
+ f, err := ioutil.TempFile(os.TempDir(), os.Args[0])
if err != nil {
panic(err)
}
defer os.Remove(f.Name())
- if _, err := f.Write(horn); err != nil {
+ if _, err := f.Write(sound); err != nil {
panic(err)
}
cmd := exec.Command("afplay", f.Name())
@@ -24,7 +24,7 @@ func main() {
}
}
-var horn = []byte{
+var sound = []byte{
0x52, 0x49, 0x46, 0x46, 0x1c, 0xa6, 0x05, 0x00, 0x57, 0x41, 0x56, 0x45,
0x66, 0x6d, 0x74, 0x20, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00,
0x44, 0xac, 0x00, 0x00, 0x10, 0xb1, 0x02, 0x00, 0x04, 0x00, 0x10, 0x00,
diff --git a/cmd/horn/horn.wav b/sound.wav
index 917ddee..917ddee 100644
--- a/cmd/horn/horn.wav
+++ b/sound.wav
Binary files differ