Difference between revisions of "ACPI hotkeys"

From ArchWiki
Jump to: navigation, search
(Old: Sample Script: Remove old method. /etc/acpi/handler.sh is the way to go.)
(Merge to main page.)
Line 1: Line 1:
[[ru:ACPI hotkeys]]
#REDIRECT [[acpid]]
[[zh-CN:ACPI hotkeys]]
[[Category:Input devices]]
There are many guides on how to configure multimedia hotkeys using program such as xev or keyTouch.  However, this guide explains how to use the simple utility of acpi_listen and generate your own script for hotkeys.
====Who Should be Using This Guide====
This guide assumes that you know your keyboard signals through acpi.  If you do not know whether or not this is the case, I suggest looking:
*[http://en.gentoo-wiki.com/wiki/Multimedia_Keys Using Multimedia Keys in Linux]
*[[Extra Keyboard Keys|Extra Keyboard Keys - keyTouch]]
====Installing Necessary Tools====
You should already have these tools installed, but just to make sure you will need
# pacman -S acpid
[[ACPI modules|Refer to this guide]] on what modules you should load (i.e. through /etc/rc.conf or modprobe)
====Using acpi_listen====
Under root, or with sufficient access to the input devices, run:
# acpi_listen
If pressing a special key, such as previous or next, receives a response that looks similar to:
hkey VALZ 00000000 00000b31
then all is well and we can continue.
If nothing appears on the screen during execution of the {{Ic|acpi_listen}}, that means that the pressed keys do not generate an ACPI event. In this case you can't use ACPI for monitoring these keys. See the page [[Hotkeys]] for other ways of mapping keys.
===Configuring ACPID===
The ACPI daemon reacts to ACPI events according to the {{ic|handler.sh}} file.  This is located in {{ic|/etc/acpi/handler.sh}}
You can either directly edit this file, to react to the ACPI events, or you can point it to another shell script (i.e.  {{ic|/etc/acpi/hotkeys.sh}})
Under the section
case "$1" in
Add the following lines:
case "$4" in
echo "PreviousButton pressed!"
exailectl p
echo "NextButton pressed!"
exailectl n
echo "Play/PauseButton pressed!"
exailectl pp
echo "executed.."
echo "StopButton pressed!"
exailectl s
echo "Hotkey Else: $4"
The '00000b31' etc. values are the response received from acpi_listen.
In 'hkey VALZ 00000000 00000b31', $4 is the final part, which was what distinguished my keys apart.
Also, the exailectl script is a brief shell script I created for controlling Exaile music player.  As the ACPID is run from root, you will need to use
sudo -u (username) exaile
for example, otherwise it will not detect your user-level program and recreate another.

Latest revision as of 02:09, 16 April 2013

Redirect to: