WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [solved] acpi /acpid - How to I configure "hotkey" event action?  (Read 8143 times)

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
I have installed acpi and acpid. When I press the power button for instance I see the messages about received event and completed event but nothing happens. The same is the case for the hotkeys. How do I go about linking the "key" events to either my or the "correct" associated scripts.

eee pc 900A
tc v2.2
« Last Edit: September 01, 2009, 10:56:16 AM by bigpcman »
big pc man

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: acpi /acpid - How to I configure "hotkey" event action?
« Reply #1 on: August 28, 2009, 02:19:37 AM »
THis may help to configure acpid:

http://www.thinkwiki.org/wiki/How_to_configure_acpid

The other option is HAL. It is bigger, requires more resources and dependencies, but HAL monitrors not only ACPI but many other events and more generic. To see HAL detected events just run

lshal -m

in a terminal after HAL installed and started.
« Last Edit: August 28, 2009, 02:24:58 AM by bmarkus »
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14820
Re: acpi /acpid - How to I configure "hotkey" event action?
« Reply #2 on: August 28, 2009, 08:59:34 AM »
As an example from the laptop-mode-tools extension:
Code: [Select]
$ cat /etc/acpi/events/lm_lid
event=button[ /]lid
action=/etc/acpi/actions/lm_lid.sh %e

Code: [Select]
$ cat /etc/acpi/actions/lm_lid.sh
#! /bin/sh

test -f /usr/sbin/laptop_mode || exit 0

# lid button pressed/released event handler

/usr/sbin/laptop_mode auto


Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: acpi /acpid - How to I configure "hotkey" event action?
« Reply #3 on: August 28, 2009, 12:30:21 PM »
As an example from the laptop-mode-tools extension:
Code: [Select]
$ cat /etc/acpi/events/lm_lid
event=button[ /]lid
action=/etc/acpi/actions/lm_lid.sh %e

Code: [Select]
$ cat /etc/acpi/actions/lm_lid.sh
#! /bin/sh

test -f /usr/sbin/laptop_mode || exit 0

# lid button pressed/released event handler

/usr/sbin/laptop_mode auto


Thanks Juanito that helped.

I have used your example and simply modified the action script to echo a message to a test file when the lid is closed/ opened. Sure enough I get messages when the lid is closed or opened. So by installing acpid and creating the files "/etc/acpid/events/lm_lid" and "/etc/acpid/actions/lm_lid.sh" followed by starting acpid ("sudo acpid") I see how I can execute my own script based on the lid.

Now I would like to use the power button and hot keys. How was the file name for the lid event determined. The event is logged as:
button/lid LID 000000xx

and the other buttons are logged as:

button/power PWRF 000000xx
button/sleep SLPB 000000xx
hotkey ATKD 000000xx

xx = a number

edit: after reading the archlinux acpid wiki I see that the events file can handle all events so the name doesn't matter it just needs to exist. All the button script links can be placed in this file.

edit2: Well I'm ready to give up. I can't seem to find an explanation of how acpid event and action file contents work that match my environment. Nothing I've tried other than the lid example works. It's as if no other "key press" is being recognized by acpid.
« Last Edit: August 28, 2009, 01:30:31 PM by bigpcman »
big pc man

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: acpi /acpid - How to I configure "hotkey" event action?
« Reply #4 on: August 28, 2009, 03:40:31 PM »
edit2: Well I'm ready to give up. I can't seem to find an explanation of how acpid event and action file contents work that match my environment. Nothing I've tried other than the lid example works. It's as if no other "key press" is being recognized by acpid.

What is about HAL?
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
[solved] acpi /acpid - How to I configure "hotkey" event action?
« Reply #5 on: August 28, 2009, 05:42:41 PM »
Alrighty then, I have figured out the errors of my way. My first stumbling block was not restarting acpid after changing events or actions. Then I began trying to restart acpid using "sudo acpid restart" after changing event or actions. That produced "acpid: can't open /proc/acpi/event: Device or resource busy" errors so I used "sudo killall acpid" instead.

It took awhile but I eventually discovered that the "keys" have new identities assigned after each restart if the "kill" command is used. Other things have to be cleaned up before the "keys" will be assigned the default values again. So every time I changed the event file to match the key event log output the subsequent acpid restart would change the key value. All this stuff makes my brain hurt.

Edit: evidently, the correct command to reload the acpid rules is:
Code: [Select]
sudo kill -SIGHUP `pidof acpid`
I don't know about other computers but for the eee pc 900a the second number in the hot key event "hotkey ATKD 000000xx 0000000xx" is incremented by 1 following each reload or restart of acpid. That's what caused my pain. As it turns out the first number is all that I needed to uniquely identify each key.
« Last Edit: August 28, 2009, 07:30:27 PM by bigpcman »
big pc man

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14820
Re: [solved] acpi /acpid - How to I configure "hotkey" event action?
« Reply #6 on: August 31, 2009, 02:18:43 AM »
It would be interesting to see what acpi events/actions you came up with

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
It would be interesting to see what acpi events/actions you came up with
Well here's what I have so far:

Code: [Select]

Event files
lid
event=button[ /]lid
action=/etc/acpi/actions/lid.sh "%e"

power
event=button[ /]power
action=/etc/acpi/actions/power.sh "%e"

f1-sleep
event=button[ /]sleep
action=/etc/acpi/actions/f1-sleep.sh "%e"

f2-wifi
event=hotkey ATKD 00000010
action=/etc/acpi/actions/f2-wifi.sh "%e"

f3
brightness down - works as is

f4
brightness up - works as is

f5-monitor
event=hotkey ATKD 00000030
action=/etc/acpi/actions/f5-monitor.sh "%e"


f6-tskmgr
event=hotkey ATKD 00000012
action=/etc/acpi/actions/f6-tskmgr.sh "%e"

f7-mute
event=hotkey ATKD 00000013
action=/etc/acpi/actions/f7-vol-mute.sh "%e"

f8-vdwn
event=hotkey ATKD 00000014
action=/etc/acpi/actions/f8-vol-dwn.sh "%e"

f9-vup
event=hotkey ATKD 00000015
action=/etc/acpi/actions/f9-vol-up.sh "%e"

The action files are a work in progress. I'll post them when I'm further along.

I am having trouble linking the power button to a script that executes "exittc" (tc2.2 using jwm).
Code: [Select]
#! /bin/sh
#
exittc
I receive the error message "Can't open display:"

edit: After a little more digging around I see I'm getting the error:
"acpid: action exited with status 127"
I have no idea what that means. I can execute the script in aterm within jwn just fine.

I want the exit menu to come up when the power button is pushed.
« Last Edit: September 01, 2009, 12:02:54 AM by bigpcman »
big pc man

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: [solved] acpi /acpid - How to I configure "hotkey" event action?
« Reply #8 on: September 01, 2009, 11:10:01 AM »
Quote
Quote from bigpcman - I am having trouble linking the power button to a script that executes "exittc" (tc2.2 using jwm).
Code:

Code: [Select]
#! /bin/sh
#
exittc
I receive the error message "Can't open display:"

Well I learned something new today. For whatever reason acpid should not be started via a remote ssh connection. That was the cause of my problems with the little power button script not executing correctly. Once I started acpid in an aterm window within jwm all was well.

Now the power button shuts down the system if I hold it down for a few seconds and brings up the exit menu if I push it momentarily.

Note I'm only using acpid, as near as I can tell acpi is not required to manage the "hotkeys" unless additional status beyond what is in the "/proc" directory is required.
big pc man

Offline ^thehatsrule^

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 1726
Re: [solved] acpi /acpid - How to I configure "hotkey" event action?
« Reply #9 on: September 08, 2009, 01:43:24 AM »
Code: [Select]
#! /bin/sh
#
exittc
I receive the error message "Can't open display:"

edit: After a little more digging around I see I'm getting the error:
"acpid: action exited with status 127"
I have no idea what that means. I can execute the script in aterm within jwn just fine.

I want the exit menu to come up when the power button is pushed.
If you mean remoting into TC machine and having the dialog showing up on that machine (not the client), set DISPLAY (i.e. export DISPLAY=:0.0 )

iirc, a status of 127 means some command couldn't be found (check PATH)

Offline jur

  • Hero Member
  • *****
  • Posts: 863
    • cycling photo essays
Re: [solved - almost] acpi /acpid - How to I configure "hotkey" event action?
« Reply #10 on: November 10, 2009, 06:54:16 PM »
The action files are a work in progress. I'll post them when I'm further along.
I am also at the point of messing about with trying to get the power button to work, and haven't actually started anything yet.

I wonder if you could post some of your stuff, along with a very brief step-by-step procedure, just to get me rolling? I have the eeepc 1000he, quite similar to the 900 I understand, so much of your stuff might work as-is for me or could be got going with some simple edits.
Thanks!