Tiny Core Linux

Tiny Core Extensions => TCE Q&A Forum => Topic started by: jur on November 15, 2009, 05:03:01 AM

Title: How to use acpid?
Post by: jur on November 15, 2009, 05:03:01 AM
When I try to use acpid, I get
Code: [Select]
acpid: can't open /proc/acpi/event: Device or resource busy
Looking at /proc/acpi/event this is an icon with a cross over it... broken link?
Title: Re: How to use acpid?
Post by: Juanito on November 15, 2009, 05:43:05 AM
Is acpid already running maybe? What is the result of "ps aux | grep acpid"?
Title: Re: How to use acpid?
Post by: jur on November 15, 2009, 02:55:59 PM
Code: [Select]
ps aux | grep acpid
   14 root     [kacpid]
11168 tc       grep acpid

I have no idea what all that means... what I'm trying to achieve is start working on making my power button work. I have no idea of where the events are sent to.

Title: Re: How to use acpid?
Post by: jur on November 15, 2009, 07:34:40 PM
OK I checked and I do have acpi and acpid in the /tce folder so these are mounted at boot. I guess I'm stuck at what to do next. I'll see if I can get some info elsewhere first.

What would be great, if a default script file could be supplied along with tc or acpid, one that handles typical power button events, one that could be modified to suit individual systems. I understand all that would be needed is to perhaps change the number that a button event generates? That would greatly ease the process of learning to live with tc.
Title: Re: How to use acpid?
Post by: Juanito on November 15, 2009, 10:26:21 PM
You could have a look at this thread for some acpi info:

http://forum.tinycorelinux.net/index.php?topic=2813.msg14648#msg14648 (http://forum.tinycorelinux.net/index.php?topic=2813.msg14648#msg14648)
Title: Re: How to use acpid?
Post by: Juanito on November 15, 2009, 10:33:46 PM
I have no idea what all that means... what I'm trying to achieve is start working on making my power button work. I have no idea of where the events are sent to.

It was a way of testing if the acpi daemon was already running - I've seen the error message you got when acpid is already running
Title: Re: How to use acpid?
Post by: jur on November 17, 2009, 04:33:08 PM
I have made some progress... at this point I can make a program execute when I press the power button. But exittc, while it works when typing this in a terminal, won't open up when pressing the power button when called from the actions file, and I'm stuck at what to do to troubleshoot. Bigpcman's thread while very helpful didn't help for that.   ???

Second problem, I haven't figured out how to enable the whole lot when rebooting. So far I have only been able to make it work by manually running sudo acpid after booting. But including acpid in bootlocal.sh didn't work. I have saved the files in /etc/acpi/events and /etc/acpi/actions in filetool and these are restored succesfully after rebooting.

Any hints?  ???
Title: Re: How to use acpid?
Post by: jur on November 18, 2009, 02:21:54 AM
* bump *
Title: Re: How to use acpid?
Post by: bigpcman on November 18, 2009, 10:15:39 AM
I have made some progress... at this point I can make a program execute when I press the power button. But exittc, while it works when typing this in a terminal, won't open up when pressing the power button when called from the actions file, and I'm stuck at what to do to troubleshoot. Bigpcman's thread while very helpful didn't help for that.   ???

Second problem, I haven't figured out how to enable the whole lot when rebooting. So far I have only been able to make it work by manually running sudo acpid after booting. But including acpid in bootlocal.sh didn't work. I have saved the files in /etc/acpi/events and /etc/acpi/actions in filetool and these are restored succesfully after rebooting.

Any hints?  ???

Could you post your event and action files and their associated permissions. Maybe Something will come to mind if we can see more specifically what you have done.
Title: Re: How to use acpid?
Post by: jur on November 18, 2009, 04:52:13 PM
I have been able to get acpid running by adding

Code: [Select]
sudo killall acpid
sudo acpid
to the .xsession file.

The power button event calls an action file

Code: [Select]
#!/bin/sh
sudo poweroff

I have tried exittc instead of sudo poweroff but somehow it simply won't be called from there. I don't know how to troubleshoot. I don't see any error msgs when running the action file in a terminal.
Title: Re: How to use acpid?
Post by: bigpcman on November 18, 2009, 04:56:49 PM
I have been able to get acpid running by adding

Code: [Select]
sudo killall acpid
sudo acpid
to the .xsession file.

The power button event calls an action file

Code: [Select]
#!/bin/sh
sudo poweroff

I have tried exittc instead of sudo poweroff but somehow it simply won't be called from there. I don't know how to troubleshoot. I don't see any error msgs when running the action file in a terminal.

Did you try "/usr/bin/exittc" ? Please post "poweroff".


This is what I have but I'm running this on mc2.2.
Code: [Select]
Event file code

power
event=button[ /]power
action=/etc/acpi/actions/power.sh "%e"

Code: [Select]
power.sh code

#! /bin/sh
#
exittc
Title: Re: How to use acpid?
Post by: Kingdomcome on November 18, 2009, 05:23:28 PM
Not to get in the middle of an acpi discussion of which I know little, let me suggest using the command "exitcheck.sh" as an automatic power down with backup.
Title: Re: How to use acpid?
Post by: jur on November 18, 2009, 05:28:08 PM
Did you try "/usr/bin/exittc" ? Please post "poweroff".
"poweroff" is a direct command not a script written by me (not sure where it is, /usr/bin?). I haven't tried "/usr/bin/exittc".

Quote
This is what I have but I'm running this on mc2.2.
Code: [Select]
Event file code

power
event=button[ /]power
action=/etc/acpi/actions/power.sh "%e"

Code: [Select]
power.sh code

#! /bin/sh
#
exittc
My code is identical except I haven't got "[ /]", only "/" - what's the difference?
Title: Re: How to use acpid?
Post by: bigpcman on November 18, 2009, 05:40:45 PM
OK, I see /sbin/poweroff is the power down command.

I don't know about the [ /] syntax I just modified the default event file.
Title: Re: How to use acpid?
Post by: jur on November 18, 2009, 06:11:25 PM
I don't know about the [ /] syntax I just modified the default event file.
Ah, just remembered I read something yesterday at http://freeos.com/guides/lsst/ch02sec11.html that it means either a space or a slash.
Title: Re: How to use acpid?
Post by: jur on November 18, 2009, 06:14:51 PM
Not to get in the middle of an acpi discussion of which I know little, let me suggest using the command "exitcheck.sh" as an automatic power down with backup.
Not at my PC now, what's in "exitcheck.sh"?
Title: Re: How to use acpid?
Post by: Kingdomcome on November 18, 2009, 07:46:01 PM
exitcheck.sh is a script written by roberts that is the backend for the exittc gui (although the comments at the head of the script still reference the dsl days)  You can view it at /usr/bin/exitcheck.sh. Basically you can call it with no options or with "exitcheck.sh shutdown" and it will backup then shutdown.  You can also backup and reboot by running "exitcheck.sh reboot"
Title: Re: How to use acpid?
Post by: jur on November 19, 2009, 05:07:13 PM
Well. Last night I decided to use the microcore new release candidate for a test drive and installed it on a partition along with other stuff.

And I just could not get the power button to operate. As far as I could see I am doing everything identically. The only difference is the rc version (rc2 vs rc1a) and using mc_rc2 vs tc_rc1a.

The lid button action works but sleep and power is steadfastly being ignored.

Very frustrating that something works in one case but the same thing does not in another case.
Title: Re: How to use acpid?
Post by: Kingdomcome on November 19, 2009, 09:19:02 PM
That probably has something to do with the other acpi errors mentioned in the rc threads.  If you had this working in TC2.5, I would expect to be able to work in 2.6final, but we'll have to see what roberts comes up with.
Title: Re: How to use acpid?
Post by: jur on November 20, 2009, 07:13:26 PM
Well I'm almost ready to give up. What worked before, for no reason I know, no longer works.

I desperately need some help: How would I detect button identifiers? I need a script that would display button IDs on screen or to a file but I am out of my depth here.
Title: Re: How to use acpid?
Post by: bigpcman on November 20, 2009, 07:55:42 PM
Well I'm almost ready to give up. What worked before, for no reason I know, no longer works.

I desperately need some help: How would I detect button identifiers? I need a script that would display button IDs on screen or to a file but I am out of my depth here.

To display button information I  modified the action script to echo a message to a test file. I think it was something simple like "echo $1 > test" but I don't remember for sure.

You could try this as mentioned in http://www.gentoo.org/doc/en/power-management-guide.xml (http://www.gentoo.org/doc/en/power-management-guide.xml) and http://wiki.archlinux.org/index.php/Acpid#Sample_Events (http://wiki.archlinux.org/index.php/Acpid#Sample_Events):

Quote
Catching ACPI events with the help of acpid. First you need to know which events are generated when the power source changes. The events are called ac_adapter and battery on most laptops, but it might be different on yours.

Code Listing 2.6: Determining ACPI events for changing the power source

# tail -f /var/log/messages | grep "received event"

Run the command above and pull the power cable. You should see something like this:

Code Listing 2.7: Sample output for power source changes

[Tue Sep 20 17:39:06 2005] received event "ac_adapter AC 00000080 00000000"
[Tue Sep 20 17:39:06 2005] received event "battery BAT0 00000080 00000001"

The interesting part is the quoted string after received event. It will be matched by the event line in the files you are going to create below.
Title: Re: How to use acpid?
Post by: jur on November 20, 2009, 11:31:00 PM
To display button information I  modified the action script to echo a message to a test file. I think it was something simple like "echo $1 > test" but I don't remember for sure.
Thanks, that's what I needed to know. It's very hard stumbling around, trying to read and absorb all the stuff on the web, not being sure if it is applicable or not. :)
Title: Re: How to use acpid?
Post by: jur on November 22, 2009, 04:25:32 PM
I am getting repeatable results now. I rewrote my scripts from scratch; I am wondering if my script name cause all my trouble - power.sh. I don't know, but it steadfastly refused to execute that script after initial promising results. I now have just one events file and one actions file with different names. And the power button now works.

Except I still am completely unable to call exittc from my scripts. exitcheck.sh works but I have never seen exittc start up via my script, even though it works just fine when called from the usual other places. I have given up on that one.

Title: Re: How to use acpid?
Post by: bigpcman on November 22, 2009, 07:56:10 PM
I am getting repeatable results now. I rewrote my scripts from scratch; I am wondering if my script name cause all my trouble - power.sh. I don't know, but it steadfastly refused to execute that script after initial promising results. I now have just one events file and one actions file with different names. And the power button now works.

Except I still am completely unable to call exittc from my scripts. exitcheck.sh works but I have never seen exittc start up via my script, even though it works just fine when called from the usual other places. I have given up on that one.



I wonder if you copied exittc to your /home/tc directory, made the file executable and perhaps renamed it if then it would execute. Kind of a brute force test that sorts things out a bit.
Title: Re: How to use acpid?
Post by: curaga on November 29, 2009, 06:52:16 AM
Since you run acpid as root, it can't start it on user tc's display - X security.

su tc -c "exittc"

Would run it as user tc, which should work.
Title: Re: How to use acpid?
Post by: Juanito on November 29, 2009, 06:57:46 AM
I was wondering about that - I just used a simple power button event and script to test the latest update to acpid.

Calling exittc, I got a segmentation fault, but calling exitcheck.sh was OK - I can see why now.

BTW, I'm sure I tried "su tc" before and it didn't work...
Title: Re: How to use acpid?
Post by: bigpcman on November 29, 2009, 10:40:24 AM
Since you run acpid as root, it can't start it on user tc's display - X security.

su tc -c "exittc"

Would run it as user tc, which should work.

Interesting.

For those that wonder what the "-c" option does:

"Among the most commonly used of su's few options is -c, which tells su to execute the command that directly follows it on the same line. Such command is executed as the new user, and then the terminal window or console from which su was run immediately returns to the account of the former user after the command has completed execution or after any program that it has launched has been closed.

If the command inclusive of its options has one or more spaces in it, then it must be enclosed in quotation marks; otherwise, su will interpret whatever comes after the first space in the command as the name of a user to whose account su is supposed to switch (the result of which will be an error message). "
Title: Re: How to use acpid?
Post by: jur on December 01, 2009, 08:26:28 AM
I have started a wiki for using acpid:
http://wiki.tinycorelinux.com/tiki-index.php?page=Using+acpid+to+control+your+PC+buttons