Can Hugo server notify with audio on error?

More frequently than I’d like (as a new Hugo user), I’m getting an error and don’t immediately realize it since my console is minimized while working.

Is there a way to force the Hugo server to audibly notify us on error/warning? A simple beep would be helpful.

Thanks,
Rick

1 Like

Please no.

It should be easy to write a wrapper shell script to create a beep if a command returns an error code.

No…

Agreed with the others, no.

But, you could do something like this (it hurts me to write this)

hugo server 2>&1 | tee /dev/tty | while read line ; do echo $line | say --rate=500 ; done

This uses the say command to read the output of hugo server, while still showing hugo server output in your console. The --rate=500 is words per minute.

It won’t beep at you, but it’ll read the actual error message to you.

4 Likes

Sounds like I’m in the minority here. Although, I’m not quite sure why one would be against an option/flag if it isn’t forced on you.

So, how do you guys set things up so that you are immediately aware of an issue (outside of having the terminal on top)?

So, how do you guys set things up so that you are immediately aware of an issue (outside of having the terminal on top)?

Usually if I make a breaking change, then http://localhost:1313/ will display nothing. From that point I’m like, “let’s check the console to see what I broke.”

Assuming macOS you could also pipe tty thru grep to check for the string ERROR since that’s consistent for errors in Hugo, then do a say to alert you. You can just say whatever; you don’t need to have it read the error.

If *nix, just use the beep command in some pattern.

1 Like

I’m on a Windows box. I’ll probably try to do something with Gulp. I’ve so far been unsuccessful getting it to work otherwise.

2 Likes

I understand that Windows 10 supports a bash terminal. Maybe that can be leveraged.

But there’s definitely a way to script it in Windows.

1 Like

@pdxDeveloper Since you’re on Windows:

  1. Download git bash and voice.exe
  2. Add voice.exe to your PATH
  3. Then in a git bash window, run something like this:
hugo server 2>&1 | tee /dev/tty | while read line ; do echo $line | if [[ $line = *"ERROR"* ]] ; then voice.exe --rate=10 ; fi ; done

It’s similar to the snippet I posted earlier, but this will only speak to you if there is output that contains ERROR.

You can play with it from here to get it to “beep” at you instead of speaking.

2 Likes

Have a look at this Stackoverflow question:

1 Like

@pdxDeveloper Looks like you can use the Windows MessageBeep function:

hugo server 2>&1 | tee /dev/tty | while read line ; do echo $line | if [[ $line = *"ERROR"* ]] ; then rundll32 user32.dll,MessageBeep ; fi ; done

See this stackoverflow thread for more info.

Thanks. I had been doing it that way in Gulp before I switched to Hugo and started using its server. I guess I got so used to it, I missed it once I stopped using Gulp.

Thanks @zwbetz. That worked perfectly! :smiley:

1 Like