# ACPI events and extra buttons

## sonicbhoc

Well, I brought the Madtux High Performance Laptop, which is pretty much a re-branded Asus laptop (but I don't know which model). So, whenever I press one of the special FN key combinations (the ones for volume and media player control), or the 4 extra buttons on the top (help, internet, mail, and something else) I get this message in my system logs:

```

ACPI group hotkey / action ATKD is not defined
```

I also get this message when I close my lid or press the sleep button. How do I define these?

----------

## sonicbhoc

*bumpity bump bump*

----------

## hans0r

i'm too lazy to write a complete guide.

google for: asus acpid

----------

## sonicbhoc

Well, whaddaya know? It's the first link too. Thanks a lot!

----------

## sonicbhoc

I've hit a snag with the mute button: this person is using aumix and I'm using amixer. The output from amixer looks like this:

```
Simple mixer control 'PCM',0

  Capabilities: pvolume

  Playback channels: Front Left - Front Right

  Limits: Playback 0 - 255

  Mono:

  Front Left: Playback 0 [0%] [-51.00dB]

  Front Right: Playback 0 [0%] [-51.00dB]

```

Now, I'm trying to make a mute script that will check to see if the volume is 0, whether it's through Playback 0, 0% or -51.00dB.

So far, all of these have failed. Trying to determine the volume level from grepping "Playback 0" I always get returned the line Limits: Playback 0.

Trying to grep 0% doesn't work because there is a 0% in 0% and 100%, so that doesn't work either.

Trying to grep -51.00dB (with or without quotes) makes grep print "Invalid option: -- ."

How do I determine whether the volume is 0% or not? If I can determine whether the volume is 0 I can finish the rest of the script my mute script myself. The rest of this stuff is going swimmingly, though.

----------

## hans0r

grep "\-51.00dB" should work

or grep "\[0%"

----------

## sonicbhoc

Thanks! I'm so close I can smell it!

Now, there's just one last problem, that I think might get a little difficult:

the buttons for play/pause, stop, next song and previous song. I use KDE, so I use amarok as my default player. I know I can control amarok through dcop, which is a cool little tool by the way. So, all of the other buttons I've set up work. But, these four don't because I have them using dcop to control amarok.

Unfortunately, when I try it, I get this error: "Could not connect to DCOP server!"

Which makes sense, because these scripts are being run as root, while dcop is being run as me. So, what do I do? 

I can't do amarok -f because then it starts Amarok as root, which is useless...

Once I get this sorted out, I'll be set.

Of course, all of these events are being run as root, so the quick buttons are useless because they'd run all of the programs I want them to run (konqueror, dolphin, konsole and firefox) as root, which is completely useless. Any way to get all of these buttons to run as a user instead of root as well?

----------

## hans0r

well, this is nicest way (and most complicated way) to assign these keys... and forces my lazy ass to write a quick and dirty howto   :Wink: 

maybe i'll write a full howto with proper explanations of each step someday.

get http://sunsite.mff.cuni.cz/pub/debian/pool/main/a/acpi-support/acpi-support_0.90.orig.tar.gz and unpack it.

edit acpi_fakekey.c and change

```

for (i=0; i<32; i++) {

```

to

```

for (i=4; i<32; i++) {

```

type make and copy acpi_fakekey to e.g. /usr/local/bin

copy all the asus files from the events folder to /etc/acpi/events

copy all the files ending with .sh to /etc/acpi (or only those that are needed by the asus events) and make sure they are executable (chmod +x)

mkdir /usr/share/acpi-support and copy key-constants there

edit/create .Xmodmap in your home folder and add the following

```

keycode 160 = XF86AudioMute

keycode 174 = XF86AudioLowerVolume

keycode 176 = XF86AudioRaiseVolume

keycode 236 = XF86Mail

keycode 178 = XF86WWW

keycode 162 = XF86AudioPlay

keycode 164 = XF86AudioStop

keycode 144 = XF86AudioPrev

keycode 153 = XF86AudioNext

```

create a file in ~/.kde/Autostart/xmodmap

```

#!/bin/sh

xmodmap ~/.Xmodmap

```

make it executable and run it once

so, that's about it. all the keys should generate proper key-events now and can be assigned to shortcuts in kde.

the volume-keys should work even without assigning them, and even with a nice osd.

----------

## sonicbhoc

 *hans0r wrote:*   

> 
> 
> edit acpi_fakekey.c and change
> 
> ```
> ...

 

This is the only thing I have a question about: what does this do?

Also, how can I be sure that the keycodes won't overwrite other existing keycodes?

----------

## sonicbhoc

It didn't work! I'm pretty sure I followed your instructions to a tee. However, none of the keys give keycodes at all! There weren't any errors in compilation, I can run acpi_fakekey (although it does nothing) and all of the scripts and events are in the right place. I double-checked the keycodes, and they were right. The scripts seem to be right too, but nothing is happening. I'd like for this to work right!

----------

## hans0r

 *sonicbhoc wrote:*   

> 
> 
> This is the only thing I have a question about: what does this do?
> 
> 

 

iirc a newer kernel version changed the order of the /dev/input/event? device nodes. that confused acpi_fakekey, so that line had to be edited.

maybe your system doesn't need it.

 *sonicbhoc wrote:*   

> 
> 
> I can run acpi_fakekey (although it does nothing) 

 

it doesn't give any output, neither when it runs successfully nor when it fails.

also it needs to be run it as root.

to test if it works you can try "acpi_fakekey 10". that's the key event for 9.

it should look like this:

```

kellerkind ~ # acpi_fakekey 10

kellerkind ~ # 9

```

----------

## sonicbhoc

I knew something was up... nothing happened!

----------

