Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] ACPID laptop suspend and hibernate? (script help)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
felixculpa
n00b
n00b


Joined: 11 Oct 2014
Posts: 12

PostPosted: Mon Nov 03, 2014 9:49 pm    Post subject: [SOLVED] ACPID laptop suspend and hibernate? (script help) Reply with quote

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
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 13994

PostPosted: Tue Nov 04, 2014 12:45 am    Post subject: Reply with quote

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
View user's profile Send private message
Yamakuzure
Advocate
Advocate


Joined: 21 Jun 2006
Posts: 2273
Location: Bardowick, Germany

PostPosted: Tue Nov 04, 2014 8:45 am    Post subject: Reply with quote

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.
_________________
Important German:
  1. "Aha" - German reaction to pretend that you are really interested while giving no f*ck.
  2. "Tja" - German reaction to the apocalypse, nuclear war, an alien invasion or no bread in the house.
Back to top
View user's profile Send private message
felixculpa
n00b
n00b


Joined: 11 Oct 2014
Posts: 12

PostPosted: Tue Nov 04, 2014 6:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
DirtyHairy
l33t
l33t


Joined: 03 Jul 2006
Posts: 608
Location: Würzburg, Deutschland

PostPosted: Wed Nov 05, 2014 6:31 am    Post subject: Reply with quote

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
Code:
lidclose.sh "$@"
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
View user's profile Send private message
felixculpa
n00b
n00b


Joined: 11 Oct 2014
Posts: 12

PostPosted: Sat Nov 08, 2014 12:48 am    Post subject: Reply with quote

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
View user's profile Send private message
palettentreter
Tux's lil' helper
Tux's lil' helper


Joined: 06 Feb 2006
Posts: 100

PostPosted: Sat Nov 08, 2014 1:23 am    Post subject: Reply with quote

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
View user's profile Send private message
felixculpa
n00b
n00b


Joined: 11 Oct 2014
Posts: 12

PostPosted: Sat Nov 08, 2014 5:57 pm    Post subject: Reply with quote

YES! The missing "esac" close was what was missing. It works now, thanks for the help.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum