aboutsummaryrefslogblamecommitdiff
path: root/generate.sh
blob: 50a0e3aac6f1ed11c414dd60eb155bba8ac5ee55 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
         
                      







                   
                         
             
                                                           



                                 
                                                 









                                               

                                                      

  
#!/bin/sh
gofmt > main.go << EOF
package main

import (
	"io/ioutil"
	"os"
	"os/exec"
)

//go:generate generate.sh
func main() {
	f, err := ioutil.TempFile(os.TempDir(), os.Args[0])
	if err != nil {
		panic(err)
	}
	defer os.Remove(f.Name())
	if _, err := f.Write(sound); err != nil {
		panic(err)
	}
	cmd := exec.Command("afplay", f.Name())
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	if err := cmd.Run(); err != nil {
		panic(err)
	}
}

var sound = []byte{
	$(xxd -i < sound.wav | sed 's/\([^,]\)$/\1,/')
}
EOF