A Cmd cannot be reused after calling its Run, Output or CombinedOutput methods
Running a command twice will not work:
cmd := exec.Command("xte", "key XF86AudioPlay")
_ := cmd.Run() // Play audio key press
// .. do something else
err := cmd.Run() // Pause audio key press, fails
Error: exec: already started
Rather, one must use two separate exec.Command
. You might also need some delay between commands.
cmd := exec.Command("xte", "key XF86AudioPlay")
_ := cmd.Run() // Play audio key press
// .. wait a moment
cmd := exec.Command("xte", "key XF86AudioPlay")
_ := cmd.Run() // Pause audio key press