LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Run script on kernel hardware event? (https://www.linuxquestions.org/questions/linux-general-1/run-script-on-kernel-hardware-event-4175592999/)

ansabhailte 11-05-2016 10:06 PM

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).

business_kid 11-09-2016 04:00 AM

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.

sundialsvcs 11-11-2016 08:17 AM

... 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.


All times are GMT -5. The time now is 02:34 AM.