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 - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 06-20-2013, 11:36 AM   #1
Refractor
Member
 
Registered: Oct 2008
Location: Rousse, Bulgaria
Distribution: Debian
Posts: 91

Rep: Reputation: 25
Question Force kernel to call hotplug script


Greetings, I have an Atheros AP123 reference board with a switch for turning on/off the wireless and a reset button. I'd like to call a script when a button is pressed. I tried creating a test hotplug script (/tmp/hotplug) with the following contents:
Code:
#!/bin/sh
echo $* >> /tmp/hotplug.log
env >> /tmp/hotplug.log
and echo '/tmp/hotplug' > /proc/sys/kernel/hotplug
but when I press a button nothing gets logged. In dmesg however I can see "Reset button pressed." or "WIFI button pressed.". I found where these get echoed (arch/mips/atheros/gpio.c) but my knowledge for the linux kernel ends there. I can modify the source but I'm not sure if I add execve calls to the kernel is a good idea. Perhaps there's some way to make the kernel call hotplug with the button on press. Any help will be greatly appreciated. Thanks!
 
Old 06-21-2013, 04:38 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,285

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
Try if acpid picks it up. Run acpid with the -l option and it will send events to syslog. You can run 'tail -f /var/log/messages' on another terminal to see.
 
1 members found this post helpful.
Old 06-27-2013, 03:29 PM   #3
Refractor
Member
 
Registered: Oct 2008
Location: Rousse, Bulgaria
Distribution: Debian
Posts: 91

Original Poster
Rep: Reputation: 25
Thanks for the tip. I ran acpid with -d to dump stuff to stdout, but then I realized that the kernel has no acpi support (no /proc/acpi or /dev/input/event0). Anyway, it's a nice tip, I have another board for a future project and I tested acpid there, it turned out great, so you really helped. Thanks!
 
  


Reply

Tags
button, gpio, hotplug, kernel



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Force hotplug permissions for usb0 ? Xeratul Debian 4 04-11-2013 09:34 AM
asterisk call out script - help understanding call files winairmvs Linux - Software 0 10-28-2010 04:52 PM
How can I script an autologin, automatically call kde(or simillar) and call an app aboaventura Slackware 8 02-03-2007 11:00 PM
How do I force hotplug to ignore a PCI slot? apsteffe Slackware 3 09-24-2006 04:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 12:29 PM.

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