Difference between revisions of "ACPI hotkeys"

From ArchWiki
Jump to: navigation, search
Line 5: Line 5:
  
 
====Who Should be Using This Guide====
 
====Who Should be Using This Guide====
If you have already used the wiki entry for [[Extra Keyboard Keys|using keyTouch]] or [[Hotkeys|just about hotkeys]] then you should look here.
+
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://gentoo-wiki.com/HOWTO_Use_Multimedia_Keys|Using Multimedia Keys in Linux]
 +
-[[Hotkeys|Hotkeys]]
 +
-[[Extra Keyboard Keys|Extra Keyboard Keys - keyTouch]]
  
 
====Installing Necessary Tools====
 
====Installing Necessary Tools====
1)  acpi
+
You should already have these tools installed, but just to make sure you will need
2)  acpid
+
3)  acpitool
+
 
  sudo pacman -S acpi acpid acpitool
 
  sudo pacman -S acpi acpid acpitool
  
====Checking that acpi_listen responds====
+
[[ACPI modules|Refer to this guide]] on what modules you should load (i.e. through /etc/rc.conf or modprobe)
In the terminal, under root run:
+
 
 +
====Using acpi_listen====
 +
Under root, or with sufficient access to the input devices, run:
 
  acpi_listen
 
  acpi_listen
  
Try pressing one of your multimedia keys, such as previous or next and you should get a response that looks similar to:
+
If pressing a special key, such as previous or next, receives a response that looks similar to:
 
  hkey VALZ 00000000 00000b31
 
  hkey VALZ 00000000 00000b31
 
+
then all is well and we can continue.
If so, then good, we can now create a script.
+
  
 
====A Sample Script====
 
====A Sample Script====
As keyTouch and other keyboard programs did not work for me, I created my own script which reacts directly to output from acpi_listen.  Here is the script, feel free to use it / modify it to suit your needs.
+
As keyTouch and other keyboard programs did not work for me, or did not work effectively, I needed to create my own script that runs in the background and reacts directly from the output of acpi_listen.  Here is the script, feel free to use it / modify it to suit your needs and post suggestions on how it can be improved.  Currently, it is setup for a Toshiba Satellite A50 laptop to control exaile, but can be modified very easily for Amarok, Xine or other non-music related functions (internet, email).
  
 
  export STOP_MYHOTKEY=0
 
  export STOP_MYHOTKEY=0
Line 53: Line 55:
 
  fi
 
  fi
  
Note:  This does not need to be run as root, if you can receive an acpi_listen response from a user accounty.
+
Note:  This does not need to be run as root if you can receive an acpi_listen response from a user account (again, meaning you have access to the input devices).

Revision as of 01:24, 22 April 2007

ACPI Hotkeys

Summary

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: -Multimedia Keys in Linux -Hotkeys -Extra Keyboard Keys - keyTouch

Installing Necessary Tools

You should already have these tools installed, but just to make sure you will need

sudo pacman -S acpi acpid acpitool

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.

A Sample Script

As keyTouch and other keyboard programs did not work for me, or did not work effectively, I needed to create my own script that runs in the background and reacts directly from the output of acpi_listen. Here is the script, feel free to use it / modify it to suit your needs and post suggestions on how it can be improved. Currently, it is setup for a Toshiba Satellite A50 laptop to control exaile, but can be modified very easily for Amarok, Xine or other non-music related functions (internet, email).

export STOP_MYHOTKEY=0
i=`acpi_listen -c 1`
case "$i" in
	"hkey VALZ 00000000 00000b31")
		#echo "PREVIOUS"
		exaile -p
		;;
	"hkey VALZ 00000000 00000b32")
		#echo "NEXT"
		exaile -n
		;;
	"hkey VALZ 00000000 00000b33")
		exaile -t
		;;
	"hkey VALZ 00000000 00000b30")
		#echo "STOP"
		exaile -s
		;;
	*)
		#echo "ELSE: $i"
		;;
esac
e=`echo $STOP_MYHOTKEY`
if [ "$e" != "1" ]
then
	./myHotkey.sh &
fi

Note: This does not need to be run as root if you can receive an acpi_listen response from a user account (again, meaning you have access to the input devices).