You are not logged in.

#1 2012-01-27 19:33:39

innn
Member
Registered: 2010-10-12
Posts: 96

cannot suspend with hibernate-script by pressing sleep button[SOLVED]

hello, I 've followed the wiki on the acpid matters and since I have hibernate-script configured and working I want it to handle my suspension also when pressing the sleep button but I have no idea what I am doing wrong
So I have this part in /etc/acpi/handler/sh:

 button/sleep)
        case "$2" in
            SBTN)
                 sudo /usr/sbin/hibernate -F /etc/hibernate/ususpend-ram.conf ;;
        esac
        ;;

and in /etc/acpi/actions/sleep-button.sh:

#!/bin/sh
case "$2" in
    SBTN)  sudo /usr/sbin/hibernate -F /etc/hibernate/ususpend-ram.conf ;;                             
    *)    logger "ACPI action undefined: $2" ;;
esac

that command is proven it works but I know for sure that I don't know actually what to write there
Please help me understand how this can be achieved
thank you

Last edited by innn (2012-02-16 06:54:06)

Offline

#2 2012-01-30 15:34:17

innn
Member
Registered: 2010-10-12
Posts: 96

Re: cannot suspend with hibernate-script by pressing sleep button[SOLVED]

no help?

Offline

#3 2012-01-30 18:46:17

Varg
Member
From: Belgium
Registered: 2010-07-07
Posts: 272

Re: cannot suspend with hibernate-script by pressing sleep button[SOLVED]

I never used that hibernate-script so I can't really provide a solution. However, doesn't pm-utils fill your needs ? In a wm it's very easy to set the sleep button as a keybind and issue a command like "sudo pm-suspend" or "sudo pm-hibernate". Works like a charm for me. When you need the sleep button in a tty that won't work though.

Offline

#4 2012-01-31 07:42:41

innn
Member
Registered: 2010-10-12
Posts: 96

Re: cannot suspend with hibernate-script by pressing sleep button[SOLVED]

@Varg thanks
I tried the pm* commands and they work, actually I should have mentioned I have nothing against using them and abandon hibernate-script but I don't know how to restart network (net-profiles service provides me with the internet connection) with pm-utils. Once resuming from suspend any user on this machine has to manually start the connection.
And more , I 've tried the sudo pm-suspend command from the terminal and it works but I don't succed in getting those config files right
Please can you share with me those parts in /etc/acpi/handler/sh and in /etc/acpi/actions/sleep-button.sh
I have them like this:

 button/sleep)
        case "$2" in
          SBTN)   sudo pm-suspend
          *)    logger "ACPI action undefined: $2" ;;               
        esac
        ;;

si

#!/bin/sh
case "$2" in
    SBTN)  sudo pm-suspend ;;
    *)    logger "ACPI action undefined: $2" ;;
esac

update: network resumes with pm-suspend and pm-hibernate here so I will use pm-utils instead of hibernate-script from now on
But,
I just have to write those files right to make the button sleep work so please help me make the required modifications
I tried with sudo pm-suspend, pm-suspend sudo /usr/sbin/pm-suspend,/usr/sbin/pm-suspend --none of them working
although simply having poweroff in case of Power Button works
in the sudoers file I have /sbin/poweroff , /usr/sbin/pm-suspend with NOPASSWD
why doesn't the Sleep button work in my case?

Last edited by innn (2012-01-31 09:05:57)

Offline

#5 2012-01-31 09:08:08

Varg
Member
From: Belgium
Registered: 2010-07-07
Posts: 272

Re: cannot suspend with hibernate-script by pressing sleep button[SOLVED]

Is the name SBTN correct for your sleep button ? Check it with the command "acpi_listen"

Actually I never used the acpi handler.sh script, but I decided that now it might be a good time to try it smile

This works for me, you only need to put this in the handler.sh:

   button/sleep)
        case "$2" in
            SBTN)   /usr/sbin/pm-suspend ;;
            *)      logger "ACPI action undefined: $2" ;;
        esac
        ;;

You don't need to put anything in /acpi/actions/, just the  handler.sh script.

Check your syntax: don't forget the ";;". There is one missing  in your part for handler.sh.

And don't forget to restart the acpi daemon.

Last edited by Varg (2012-01-31 09:12:48)

Offline

#6 2012-01-31 17:10:16

innn
Member
Registered: 2010-10-12
Posts: 96

Re: cannot suspend with hibernate-script by pressing sleep button[SOLVED]

ok, I 've deleted files in /etc/acpi/actions and modified handler.sh to look just like yours but it doesn't work
acpi_listen says SBTN
those are the exact lines actually tried even deleting what was there and copy-pasting your lines
and sudo pm-suspend and sudo pm-hibernate both work when I try them from the command line
also in the same handler.sh file I have poweroff assigned to the PBTN and pressing said button works

I have acpid restarted every time I modify that file
I tried putting back the original lines as per acpid wiki with echo -n mem >/sys/power/state and not working either
is something maybe interfering here?
is there something else I should mention like I am using openbox started from x with exec ck-launch-session dbus-launch openbox ?
I don't know things like this drive me nuts

Last edited by innn (2012-01-31 17:13:30)

Offline

#7 2012-01-31 20:02:05

innn
Member
Registered: 2010-10-12
Posts: 96

Re: cannot suspend with hibernate-script by pressing sleep button[SOLVED]

Varg wrote:

I never used that hibernate-script so I can't really provide a solution. However, doesn't pm-utils fill your needs ? In a wm it's very easy to set the sleep button as a keybind and issue a command like "sudo pm-suspend" or "sudo pm-hibernate". Works like a charm for me. When you need the sleep button in a tty that won't work though.

I've read it twice and only second time I've understood smile , now I am glad I 've tried this cause it works so  I've  put two keybindings in openbox for XF86Sleep and XF86PowerOff with pm-suspend and pm-hibernate.
Now I have a slightly different problem I want to make pm-utils resume my internet connection automatically without having me trigger it manually every time but I do not know what the file should look like in the /etc/pm/
The services I am interest in are network and net-profiles (it's a pppoe conenction), when I execute pm-suspend and come back I have to restart net-profiles to have internet access
Can you help me with this as well?

Offline

#8 2012-02-01 16:34:30

Varg
Member
From: Belgium
Registered: 2010-07-07
Posts: 272

Re: cannot suspend with hibernate-script by pressing sleep button[SOLVED]

Can't really help with that. I used netcfg with net-auto-wireless before which seemed to work. I stick with Wicd as my network manager. Easy to use, and it has both gtk and cli interfaces.

Offline

#9 2012-02-02 10:33:38

noMaster
Member
Registered: 2009-07-05
Posts: 70

Re: cannot suspend with hibernate-script by pressing sleep button[SOLVED]

@Innn
I use Networkmanager and it works pretty good for me

Offline

#10 2012-02-16 06:53:53

innn
Member
Registered: 2010-10-12
Posts: 96

Re: cannot suspend with hibernate-script by pressing sleep button[SOLVED]

it's ok , it works

Offline

Board footer

Powered by FluxBB