# ACPI not able to run amixer

## ZmjbS

I've been struggling with getting my acpi scripts working. I've narrowed the issue to what seems like a permission problem, but am unsure how to solve it.

Running commands in acpi scripts works only if they're run as a normal user. How do I run them without such a cludge?

Specifically, given (/etc/acpi/default.sh)

```
[...]

case "$group" in

   button)

      case "$action" in

         power)

            /etc/acpi/actions/powerbtn.sh

            ;;

         volumedown)

            /etc/acpi/actions/volume.sh down

            ;;

         volumeup)

            /etc/acpi/actions/volume.sh up

            ;;

[...]

```

and (/etc/acpi/actions/volume.sh)

```
#!/bin/bash

case "$1" in

   up)

      su martin -c "amixer set Master 5%+ unmute"

   ;;

   down)

      su martin -c "amixer set Master 5%- unmute"

   ;;

   mute)

      su martin -c "amixer set Master toggle"

   ;;

esac
```

I'm able to get the volume keys to work. If I run amixer without su-ing to the user martin, things break.

Ideas?

----------

## Ant P.

Very weird that root isn't able to see your ALSA hardware...

What does `amixer` on its own print when run as root and as normal user?

----------

## ZmjbS

 *Ant P. wrote:*   

> Very weird that root isn't able to see your ALSA hardware...
> 
> What does `amixer` on its own print when run as root and as normal user?

 

Yes, it is. I tried adding root to the audio group, but no use.

```
$ amixer

Simple mixer control 'Master',0

  Capabilities: pvolume pswitch pswitch-joined

  Playback channels: Front Left - Front Right

  Limits: Playback 0 - 65536

  Mono:

  Front Left: Playback 65536 [100%] [on]

  Front Right: Playback 65536 [100%] [on]

Simple mixer control 'Capture',0

  Capabilities: cvolume cswitch cswitch-joined

  Capture channels: Front Left - Front Right

  Limits: Capture 0 - 65536

  Front Left: Capture 16462 [25%] [on]

  Front Right: Capture 16462 [25%] [on]
```

```
# amixer

ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

amixer: Mixer attach default error: Connection refused
```

----------

## wahrwolf

i have the same problem:

tried to config acpid for volume-control, but failed.

the strange thing is that i can ran any other command without trouble.

so i tried to pipe the output from amixer to logger:

My handler looks like:

```

#!/bin/bash

#Handler for audio-managment

case "$1" in

   +)

      logger 'Volume raised'

      amixer -q set Master 5%+

      ;;

   -)

      logger 'Volume down'

      amixer -q set Master 5%-

      ;;

   t)

      logger 'Volume toggle mute'

      amixer | logger

      ;;

esac

```

when i hit the button for toogle (button/mute) in my case i get:

```

Jul 05 22:31:00 archwolf root[1326]: Volume toggle mute

Jul 05 22:31:00 archwolf root[1326]: Simple mixer control 'IEC958',0

Jul 05 22:31:00 archwolf root[1326]:   Capabilities: pswitch pswitch-joined

Jul 05 22:31:00 archwolf root[1326]:   Playback channels: Mono

Jul 05 22:31:00 archwolf root[1326]:   Mono: Playback [on]

```

but when running amixer as normal user (and as root) i get:

```

Simple mixer control 'Master',0

  Capabilities: pvolume pswitch pswitch-joined

  Playback channels: Front Left - Front Right

  Limits: Playback 0 - 65536

  Mono:

  Front Left: Playback 19755 [30%] [on]

  Front Right: Playback 19755 [30%] [on]

Simple mixer control 'Capture',0

  Capabilities: cvolume cswitch cswitch-joined

  Capture channels: Front Left - Front Right

  Limits: Capture 0 - 65536

  Front Left: Capture 65535 [100%] [off]

  Front Right: Capture 65535 [100%] [off]

```

I am using ALSA + Pulseaudio ...

any ideas?

ps sry for bad english  :Wink: 

----------

