79664127

Date: 2025-06-12 21:37:48
Score: 0.5
Natty:
Report link

I discovered from a Linux Mint Forum topic that what I was missing is making sure the current user had sufficient permissions (the error messages gave me no indication that it was a permission issue, but turns out, it was).

I moved the command into a Bash script named setVolume.sh (making sure it has the correct permissions with chmod), with the user myuser being part of the group for /usr/bin/amixer:

sudo su - myuser
amixer -c 3 set PCM 50%

Then, I changed Go code to:

package main

import (
    "fmt"
    "log"
    "os"
    "os/exec"
)

func main() {
    setVolumeCommand := exec.Command("/bin/sh", "./setVolume.sh")
    setVolumeCommand.Stdout = os.Stdout
    setVolumeCommand.Stderr = os.Stderr
    setVolumeError := setVolumeCommand.Run()
    if setVolumeError != nil {
        log.Fatal(setVolumeError)
    }
}

Thanks for helping me figure this out!

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: The-Coder-Who-Knew-Too-Little