View previous topic :: View next topic |
Author |
Message |
felixculpa n00b
Joined: 11 Oct 2014 Posts: 12
|
Posted: Mon Nov 03, 2014 9:49 pm Post subject: [SOLVED] ACPID laptop suspend and hibernate? (script help) |
|
|
Hi everyone. It's been awhile since I've had to use acpid (not since my Archbang days) but anyway my suspend setup is not working. I have the kernel options enabled, pm-utils installed, the script files chmoded with +x and I inserted the following in /etc/acpi/default.sh Code: | lid)
/etc/acpi/actions/lidclose.sh
;; | right under Code: | case "$group" in
button)
case "$action" in
power)
/etc/acpi/actions/powerbtn.sh
;; | and finally in /etc/acpi/actions/lidclose.sh is the following: Code: | #!/bin/sh
case $3 in
close)
/usr/sbin/pm-suspend &
DISPLAY=:0.0 su -c - "<my-user-name>" /usr/bin/slock;;
open) :;; | I would restart the acpid service and close the lid but nothing happens. The individual commands in the scripts work if I type them out manually. I am probably missing something obvious here as I don't really actually understand scripts, I just put this together from what I gathered elsewhere. I would like to be able to hibernate as well, and I created a swapfile and will probably be able to figure out how to invoke pm-hibernate through acpid once I find out what is wrong with the suspend script.
Last edited by felixculpa on Sat Nov 08, 2014 5:56 pm; edited 1 time in total |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 23091
|
Posted: Tue Nov 04, 2014 12:45 am Post subject: |
|
|
Does your system generate an ACPI lid event when you close the lid? Some systems use strange names or fail to generate seemingly obvious events. I would start by setting the lid close action to be a command that leaves obvious evidence it ran, such as date >> well-known-file. Then close the lid and check whether the current date was written. If yes, then your problem is with the suspend commands. If no, then your problem is that acpid is not reporting the lid closure in a way that the script recognizes or that acpid is not reporting a lid closure at all. |
|
Back to top |
|
|
Yamakuzure Advocate
Joined: 21 Jun 2006 Posts: 2305 Location: Adendorf, Germany
|
Posted: Tue Nov 04, 2014 8:45 am Post subject: |
|
|
You are just calling your lidclose.sh without any arguments but rely on argument 3 to be "close" in the script. So it seems you are missing an "$@" there. _________________ Edited 220,176 times by Yamakuzure |
|
Back to top |
|
|
felixculpa n00b
Joined: 11 Oct 2014 Posts: 12
|
Posted: Tue Nov 04, 2014 6:36 pm Post subject: |
|
|
I think you are both on to something. Putting in date >> file didn't put anything into the file. I'm not sure what Yamakuzure means with the $@. In /etc/acpi/default.sh there is this: Code: | #!/bin/sh
# /etc/acpi/default.sh
# Default acpi script that takes an entry for all actions
set $*
group=${1%%/*}
action=${1#*/}
device=$2
id=$3
value=$4 | at the top. I assumed the scripts under the actions directory would simply be appended, in a way and read the settings in default.sh, specifically the id=$3 part? Perhaps I should just take the scripts under the actions directory and put them into default.sh? |
|
Back to top |
|
|
DirtyHairy l33t
Joined: 03 Jul 2006 Posts: 608 Location: Würzburg, Deutschland
|
Posted: Wed Nov 05, 2014 6:31 am Post subject: |
|
|
Yamakuzure is correct. Nothing is magically read or appended anywhere; lidclose.sh is run as a separate command in its own shell. $3 refers to the third command line argument, and as you run the script without arguments, it will always be empty. You need to call the script as in order to pass the arguments of default.sh to lidclose.sh - "$@" will be substituted with the argument list by the shell. |
|
Back to top |
|
|
felixculpa n00b
Joined: 11 Oct 2014 Posts: 12
|
Posted: Sat Nov 08, 2014 12:48 am Post subject: |
|
|
Still doesn't work, something else is obviously wrong. Here are the files:
/etc/acpi/default.sh Code: | #!/bin/sh
set $*
group=${1%%/*}
action=${1#*/}
device=$2
id=$3
value=$4
log_unhandled() {
logger "ACPI event unhandled: $*"
}
case "$group" in
button)
case "$action" in
power)
/etc/acpi/actions/powerbtn.sh ;;
lid)
/etc/acpi/actions/lidclose.sh $@ ;;
*) log_unhandled $* ;;
esac
;;
ac_adapter)
case "$value" in
*) log_unhandled $* ;;
esac
;;
*) log_unhandled $* ;;
esac |
/etc/acpi/actions/lidclose.sh
Code: | #!/bin/sh
case $3 in
close)
/usr/sbin/pm-suspend &
DISPLAY=:0.0 su -c - <my user name> /usr/bin/slock;;
open) :;; |
There is probably either a syntax error or a character that either shouldn't be in there or should be something else... |
|
Back to top |
|
|
palettentreter Tux's lil' helper
Joined: 06 Feb 2006 Posts: 104
|
Posted: Sat Nov 08, 2014 1:23 am Post subject: |
|
|
Well first of all, in lidclose.sh, you're not closing the "case" statement. It should be:
Code: |
#!/bin/sh
case $3 in
close)
/usr/sbin/pm-suspend &
DISPLAY=:0.0 su -c - "<my-user-name>" /usr/bin/slock;;
open) :;;
esac
|
Then try running "/etc/acpi/actions/lidclose.sh what ever close" in your shell and see if that works. If it does, you should be fine, the rest looks OK to me now. |
|
Back to top |
|
|
felixculpa n00b
Joined: 11 Oct 2014 Posts: 12
|
Posted: Sat Nov 08, 2014 5:57 pm Post subject: |
|
|
YES! The missing "esac" close was what was missing. It works now, thanks for the help. |
|
Back to top |
|
|
|