LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-05-2016, 10:06 PM   #1
ansabhailte
LQ Newbie
 
Registered: Nov 2016
Posts: 1

Rep: Reputation: Disabled
Run script on kernel hardware event?


I'm working on an ARM Chromebook with Debian (so no ACPI) and want to run a script when the lid closes. I can't find anything relevant in xinput, but evtest shows the close and open state change. The way I see it, I'd basically need to write a small daemon to listen for specific ioctl() calls (the event is an EV_SW event), and then run a script when it receives the call. How would I go about this? I'm proficient in bash/sed/awk, but don't know C (am willing to learn, however).
 
Old 11-09-2016, 04:00 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,371

Rep: Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335
Before ACPI, laptop power saving was handled through something called APM. I think it's gone from the kernel now, but if you go back in the versions you will find it. Failing that, you will have to discover how you detect the hardware event.
 
Old 11-11-2016, 08:17 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
... on most laptops, there's already an "on sleep" or "on lid close" mechanism in place, causing the OS to "hibernate." You should be able to find that and tap into it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Squid run script on access_denied event markotitel Linux - Server 3 04-19-2013 03:24 PM
Run a script on switch-user event Ubuntu 9.10 bwilhite Programming 6 02-20-2010 07:44 AM
How to make the right mouse button run a script (event trigger) xmrkite Linux - Hardware 5 10-17-2006 01:29 PM
run script at hotplug event AAnarchYY Linux - Hardware 1 07-21-2006 09:19 AM
how to run script on event ppp0 interface going down ? qwijibow Linux - Networking 4 02-24-2004 06:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration