notify_linux.go 556 B

1234567891011121314151617181920212223242526272829
  1. package main
  2. import (
  3. "fmt"
  4. "os/exec"
  5. "gopkg.in/errgo.v1"
  6. )
  7. func notify(passed bool, output string) error {
  8. lvl := "critical"
  9. title := "test failed"
  10. if passed {
  11. lvl = "normal"
  12. title = "test passed"
  13. }
  14. tout := fmt.Sprintf("%.0f", timeout.Seconds()*1000)
  15. if len(output) > 300 {
  16. output = output[:300]
  17. }
  18. output = `'` + output + `'`
  19. xmsg := exec.Command("notify-send", "-t", tout, "-u", lvl, title, output)
  20. out, err := xmsg.CombinedOutput()
  21. if err != nil {
  22. return errgo.Notef(err, "notify-send failed: output: %s", out)
  23. }
  24. return nil
  25. }