Custom hot key programming with acpid

Hooking the Script to acpid

Getting acpid to use your script is really just a matter of editing the /etc/acpi/event/ibm-videobtn file and replacing the action= line with a pointer to your script. On my system, the script is /usr/local/sbin/video-switch, so my ibm-videobtn file looks like this:

event=ibm/hotkey HKEY 00000080 00001007
action=/usr/local/sbin/video-switch

When you modify the files under /etc/acpi/events, you'll need to restart acpid to get it to pick up the changes.

Additionally, you'll want to get acpid out of debug mode, so hit Ctrl+C in the window in which acpid is currently running then enter /etc/init.d/acpid start as root to fire up the daemon normally. At this point, hitting Fn+F7 on the laptop should cycle it through the three display settings programmed in the script. Because this very simple hack works as advertised, I've gotten tons of "geek cred" at various Linux User Group meetings.

Summary

Programming your own hot key hacks is equally simple. First, run acpid in debug mode to figure out exactly which event is triggered by your key presses. Then check the /etc/acpi/event directory to see whether a configuration file related to this event already exists. If not, feel free to create one from scratch – you really only need the event= and action= lines for most simple events. From there, it's just a matter of scripting what you want to happen. In many cases, you might be able to find example scripts on the web to use as a starting point.

Infos

  1. Advanced Configuration and Power Interface: http://www.acpi.info/
  2. acpid: http://sourceforge.net/projects/acpid/
  3. ThinkWiki sample script: http://www.thinkwiki.org/wiki/Sample_Fn-F7_script

The Author

Hal Pomeranz (mailto:hal@deer-run.com) is an independent consultant with more than 20 years of experience with Unix. He is a Faculty Fellow of the SANS Institute and the course author and primary instructor for their Linux/Unix Security certification track. Hal is also a recipient of the SAGE Outstanding Achievement award for his teaching and leadership in the field of Systems Administration.

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Multi-heading with RandR

    The RandR X server extension gives users more intuitive control over video projectors and multi-head installations.

  • Ask Klaus!

    Klaus Knopper is the creator of Knoppix and co-founder of the LinuxTag expo. He currently works as a teacher, programmer, and consultant. If you have a configuration problem, or if you just want to learn more about how Linux works, send your questions to: klaus@linux-magazine.com

  • ASK KLAUS!

    Klaus Knopper is the creator of Knoppix and co-founder of the LinuxTag expo. He currently works as a teacher, programmer, and consultant. If you have a configuration problem, or if you just want to learn more about how Linux works, send your questions to: klaus@linux-magazine. com

  • Custom Resolutions

    You can boost productivity on an old laptop using xrandr to quickly and easily gain some extra screen real estate.

  • Ask Klaus!

    Klaus Knopper is the creator of Knoppix and co-founder of the LinuxTag expo. He currently works as a teacher, programmer, and consultant. If you have a configuration problem, or if you just want to learn more about how Linux works, send your questions to: klaus@linux-magazine.com

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News