FS#7593 - acpid update breaks acpi scripts using 'if then fi'

Attached to Project: Arch Linux
Opened by Shira K (Shirakawasuna) - Tuesday, 10 July 2007, 01:54 GMT
Last edited by Thayer Williams (thayer) - Saturday, 06 December 2008, 21:05 GMT
Task Type Bug Report
Category System
Status Closed
Assigned To Tobias Powalowski (tpowa)
Thayer Williams (thayer)
Architecture All
Severity Medium
Priority Normal
Reported Version 2007.05 Duke
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description: After upgrading to acpid-1.0.6-1, I noticed that my laptop would no longer go to sleep upon closing its lid. After much investigation, it seems that acpid doesn't like my script in /etc/acpid/actions/lid.sh. This script *should* work - it works when executed from the cli while the lid is open and I change grep "closed" to grep "open" and it works if I use the outputted file from the 'cat' line and have it 'echo "hello world"'.
If I remove the if-then-fi statements and leave any more basic command, for instance the 'cat' section or adding 'hibernate', the command execute when I close the lid.

Downgrading resolves this issue.

Additional info:
* package version(s)
acpid-1.0.6-1
* config and/or log files etc.
the lid.sh script:
[code]
#!/bin/bash
# When the display is "being closed", the state is already closed
sleep 5
if grep "closed" /proc/acpi/button/lid/LID/state
then cat /proc/acpi/button/lid/LID/state >> /home/nick/lid.log
fi
[/code]


Steps to reproduce: create an /etc/acpi/actions script that has an if-then-fi sequence such that you know if it has worked or not, chmod +x it, tie it to an event with an /etc/acpi/events script, restart acpid and cause said event.
This task depends upon

Closed by  Thayer Williams (thayer)
Saturday, 06 December 2008, 21:05 GMT
Reason for closing:  Works for me
Comment by Riri (chicha) - Friday, 09 May 2008, 12:40 GMT
Hello,

This problem is 10 months old.
Is this still valid ? Did you found a solution ?
Comment by Adrian C. (anrxc) - Thursday, 05 June 2008, 12:03 GMT
Hi, I have a similar if not the same problem with:
acpid 1.0.6-1

I have one handler with an if statement that locks my desktop if the display is closed.

This is the behaviour:
* upon boot all other handlers except that one work
** if I do /etc/rc.d/acpid restart, from that point on that handler also works
* I replaced it with a command that gets the status of the lid and writes it to a file, it works after a boot, and lid status is correctly updated upon booting
Comment by Shira K (Shirakawasuna) - Saturday, 21 June 2008, 04:49 GMT
This issue is still present for me. If I run the 'actions' script from a terminal (no acpi changes, lids being shut/opened, etc), it works fine if I set the grep value being sought after to "open". Note that whether I set the value to "open" or "closed", it doesn't work when I actually close the lid. I'll be trying to ssh into the box while closed just to double check, but I believe that last time I did so the value was indeed "closed" :/.

The test script is about the same:
if grep "open" /proc/acpi/button/lid/LID/status
then
echo "hello" >> /etc/acpi/hello
else
echo "goodbye" >> /etc/acpi/hello
fi

Strangely enough, I get two 'goodbye' messages every time no matter which input I put in and no matter how obvious the 'grep' is. I would chalk this up to it receiving multiple events, but the log says it only gets one :/.
Comment by Thayer Williams (thayer) - Tuesday, 02 December 2008, 02:52 GMT
I just adopted this package today and am seeing similar behaviour with respect to double 'lid closed' events. It's actually suspending my notebook twice. Upgrading to 1.0.8 doesn't address this so I'll have a look at our handler.sh and see if something else could be afoot. Stay tuned...
Comment by Adrian C. (anrxc) - Tuesday, 02 December 2008, 13:06 GMT
What I reported is still true with 1.0.8. After booting the handler doesn't work, if I restart acpid the handler works.
Comment by Thayer Williams (thayer) - Wednesday, 03 December 2008, 02:18 GMT
I think this may be related to custom handler scripts. I was able to get things worked as expected with the following:

button/lid)
#echo "LID switched!">/dev/tty5
grep -q closed /proc/acpi/button/lid/*/state
if [ $? = 0 ]; then
echo -n mem >/sys/power/state
fi
;;

This works upon initial startup and subsequent suspend/resumes. Unless I hear otherwise, I'm going to close this ticket.
Comment by Adrian C. (anrxc) - Saturday, 06 December 2008, 19:44 GMT
That is the code I use, but a different command, and it seems that is the problem. I call xlock. When acpid is started X is not yet running but that shouldn't be a problem because the handler is called only after X is started; DISPLAY and everything is set by that time... Well apparently I'm wrong, I replaced xlock command with an echo of the status and it works fine upon booting. (I recall trying this with 1.0.6 with no results, closing this ticket is fine by me)

Any suggestions or explanations about the xlock issue are welcome. For the record I call it like this:
if ...
sudo -u user /usr/bin/xlock
#su - user -c /usr/bin/xlock
fi
Comment by Thayer Williams (thayer) - Saturday, 06 December 2008, 21:04 GMT
Sorry, I have no experience with xlock, but I do know that xscreensaver and slock work OK for me when using the above if/then conditions.

I'll close this for now.

Loading...