Enable suspend on lid close?

Post here if you are a new Porteus member and you're looking for some help.
tome
Contributor
Contributor
Posts: 675
Joined: 26 Jun 2013, 14:03
Distribution: x64 Openbox
Location: Russia is causing the immense damage to humanity
Contact:

Re: Enable suspend on lid close?

Post#31 by tome » 20 Jan 2014, 18:54

Maybe you need close lid more than only black screen, try this: url deleted (file is in my dropbox - examples folder)
paste also this in terminal, close lid (partial but enough), press Enter, open lid and see output.
Sorry
paste

Code: Select all

cat /proc/acpi/button/lid/LID/state
:good:
Last edited by tome on 20 Jan 2014, 19:36, edited 1 time in total.
You have mind and feelings. Be wise and clever.

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Re: Enable suspend on lid close?

Post#32 by Ed_P » 20 Jan 2014, 19:29

Good news, bad news.

Bad news 1st. I get a 403 error when I click on your link.

Good news. Before I went out to shovel snow I manually Suspended the netbook and closed the cover. When I came in opened the cover and read your posting, made the acpi_handle.sh change you posted, closed the lid to see if I could press Enter, I couldn't but the system went into suspend mode!!!!!!!! :shock: I tried closing and reopening the lid several times and each time suspend mode is working,

I will reboot and retry in case this is a fluke.
Ed

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Re: Enable suspend on lid close?

Post#33 by Ed_P » 20 Jan 2014, 19:46

Reboot, closed lid, no suspend. Manually suspended via desktop icon, activated, closed lid, no suspend. Manually suspended via Leave options, activated, closed lid, no suspend.

What happened???????? :wall:
Ed

tome
Contributor
Contributor
Posts: 675
Joined: 26 Jun 2013, 14:03
Distribution: x64 Openbox
Location: Russia is causing the immense damage to humanity
Contact:

Re: Enable suspend on lid close?

Post#34 by tome » 20 Jan 2014, 19:49

Have you saved your session and acpi_handler?
You have mind and feelings. Be wise and clever.

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Re: Enable suspend on lid close?

Post#35 by Ed_P » 20 Jan 2014, 19:55

Changes were saved and acpi_handler.sh changes are present.
Ed

tome
Contributor
Contributor
Posts: 675
Joined: 26 Jun 2013, 14:03
Distribution: x64 Openbox
Location: Russia is causing the immense damage to humanity
Contact:

Re: Enable suspend on lid close?

Post#36 by tome » 20 Jan 2014, 19:59

try this: https://www.dropbox.com/sh/ui4ydoh3j34x ... handler.sh copy text or file (but for file set correct permissions)
You have mind and feelings. Be wise and clever.

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Re: Enable suspend on lid close?

Post#37 by Ed_P » 20 Jan 2014, 20:08

Downloaded, copied, no change.

Code: Select all

guest@porteus:~$ su
Password: 
root@porteus:/home/guest# cp /home/guest/Downloads/acpi_handler.sh etc/acpi
cp: cannot create regular file ‘etc/acpi’: No such file or directory
root@porteus:/home/guest# cp /home/guest/Downloads/acpi_handler.sh /etc/acpi/
root@porteus:/home/guest# 
Ed

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Re: Enable suspend on lid close?

Post#38 by Ed_P » 20 Jan 2014, 20:42

BTW & FWIW

Code: Select all

root@porteus:/home/guest# echo -n mem
memroot@porteus:/home/guest# acpi_handler.sh
bash: acpi_handler.sh: command not found
root@porteus:/home/guest# /etc/acpi/acpi_handler.sh
BASH=/bin/sh
BASHOPTS=cmdhist:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()
BASH_LINENO=([0]="0")
BASH_SOURCE=([0]="/etc/acpi/acpi_handler.sh")
BASH_VERSINFO=([0]="4" [1]="2" [2]="37" [3]="2" [4]="release" [5]="x86_64-slackware-linux-gnu")
BASH_VERSION='4.2.37(2)-release'
BROWSER=firefox
CPLUS_INCLUDE_PATH=/usr/lib64/qt/include:/usr/lib64/qt/include:/usr/lib64/qt/include:/usr/lib64/qt/include
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-utBKfG8NXE,guid=d2fa9be687b897dd8113ea1000000014
DESKTOP_SESSION=razor.desktop
DIRSTACK=()
DISPLAY=:0.0
EUID=0
GDK_USE_XFT=1
GROUPS=()
GTK2_RC_FILES=/home/guest/.gtkrc-2.0
G_BROKEN_FILENAMES=1
G_FILENAME_ENCODING=@locale
HOME=/root
HOSTNAME=porteus.example.net
HOSTTYPE=x86_64
IFS=' 	
/'
INPUTRC=/etc/inputrc
LANG=en_US.UTF-8
LC_COLLATE=C
LESS=-M
LESSOPEN='|lesspipe.sh %s'
LOGNAME=root
LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.bat=01;32:*.BAT=01;32:*.btm=01;32:*.BTM=01;32:*.cmd=01;32:*.CMD=01;32:*.com=01;32:*.COM=01;32:*.dll=01;32:*.DLL=01;32:*.exe=01;32:*.EXE=01;32:*.7z=01;31:*.ace=01;31:*.ACE=01;31:*.arj=01;31:*.bz2=01;31:*.cpio=01;31:*.deb=01;31:*.dz=01;31:*.gz=01;31:*.jar=01;31:*.lzh=01;31:*.lzma=01;31:*.rar=01;31:*.RAR=01;31:*.rpm=01;31:*.rz=01;31:*.tar=01;31:*.taz=01;31:*.tb2=01;31:*.tbz2=01;31:*.tbz=01;31:*.tgz=01;31:*.tlz=01;31:*.trz=01;31:*.txz=01;31:*.tz=01;31:*.tz2=01;31:*.xz=01;31:*.z=01;31:*.Z=01;31:*.zip=01;31:*.ZIP=01;31:*.zoo=01;31:*.aac=01;35:*.AAC=01;35:*.anx=01;35:*.asf=01;35:*.ASF=01;35:*.au=01;35:*.axa=01;35:*.axv=01;35:*.avi=01;35:*.AVI=01;35:*.bmp=01;35:*.BMP=01;35:*.divx=01;35:*.DIVX=01;35:*.flac=01;35:*.FLAC=01;35:*.gif=01;35:*.GIF=01;35:*.jpg=01;35:*.JPG=01;35:*.jpeg=01;35:*.JPEG=01;35:*.m2a=01;35:*.M2A=01;35:*.m2v=01;35:*.M2V=01;35:*.m4a=01;35:*.M4A=01;35:*.m4p=01;35:*.M4P=01;35:*.m4v=01;35:*.M4V=01;35:*.mid=01;35:*.midi=01;35:*.mka=01;35:*.mkv=01;35:*.MKV=01;35:*.mov=01;35:*.MOV=01;35:*.mp3=01;35:*.MP3=01;35:*.mp4=01;35:*.MP4=01;35:*.mp4v=01;35:*.mpc=01;35:*.MPC=01;35:*.mpeg=01;35:*.MPEG=01;35:*.mpg=01;35:*.MPG=01;35:*.nuv=01;35:*.oga=01;35:*.ogv=01;35:*.ogx=01;35:*.ogg=01;35:*.OGG=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.PNG=01;35:*.ppm=01;35:*.qt=01;35:*.ra=01;35:*.RA=01;35:*.ram=01;35:*.RAM=01;35:*.rm=01;35:*.RM=01;35:*.spx=01;35:*.svg=01;35:*.svgz=01;35:*.tga=01;35:*.TGA=01;35:*.tif=01;35:*.TIF=01;35:*.tiff=01;35:*.TIFF=01;35:*.vob=01;35:*.VOB=01;35:*.wav=01;35:*.WAV=01;35:*.wma=01;35:*.WMA=01;35:*.wmv=01;35:*.WMV=01;35:*.xbm=01;35:*.xcf=01;35:*.xpm=01;35:*.xspf=01;35:*.xwd=01;35:*.XWD=01;35:*.xvid=01;35:'
LS_OPTIONS='-F -b -T 0 --color=auto'
MACHTYPE=x86_64-slackware-linux-gnu
MANPATH=/usr/local/man:/usr/man
MINICOM='-c on'
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/lib64/qt/bin
PIPESTATUS=([0]="0")
POSIXLY_CORRECT=y
PPID=5062
PS4='+ '
PWD=/home/guest
QT4DIR=/usr/lib64/qt
QT_PLUGIN_PATH=:/usr/lib64/qt/plugins
SHELL=/bin/bash
SHELLOPTS=braceexpand:hashall:interactive-comments:posix
SHLVL=3
TERM=xterm
UID=0
USER=root
XAUTHORITY=/home/guest/.Xauthority
XDG_CONFIG_DIRS=/etc/xdg:/etc/xdg:/etc/xdg:/etc/xdg:/etc/xdg
XDG_CURRENT_DESKTOP=Razor
XDG_MENU_PREFIX=razor-
XDG_SESSION_COOKIE=c4ba8421389ff4ed753e969200000007-1390228583.232732-1704801605
_=
cat: /proc/acpi/button/lid/LID0/state: No such file or directory
root@porteus:/home/guest# 
Ed

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Re: Enable suspend on lid close?

Post#39 by Ed_P » 20 Jan 2014, 23:44

Ok, the problem is I'm flying as blind as a bat.

This works:

Code: Select all

#!/bin/sh
# Default acpi script that takes an entry for all actions

IFS=${IFS}/
set $@

case "$1" in
  button)
    case "$2" in
      power) /sbin/init 0    
         ;;
      lid) 
           case "$3" in
             close) /usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
               ;;
           esac 
         ;;
      *) logger "ACPI action $2 is not defined"
         ;;
    esac
    ;;
  *)
    logger "ACPI group $1 / action $2 is not defined"
    ;;
esac

case $(cat /proc/acpi/button/lid/LID/state | awk '{print $2}') in
    closed) echo -n mem >/sys/power/state
;;
esac
case $(cat /proc/acpi/button/lid/LID0/state | awk '{print $2}') in
    closed) echo -n mem >/sys/power/state
;;
esac
IF I do this:

Code: Select all

root@porteus:/home/guest#  /etc/acpi/acpi_handler.sh button lid close
method return sender=:1.14 -> dest=:1.57 reply_serial=2
cat: /proc/acpi/button/lid/LID0/state: No such file or directory

The problem is apparently when the lid is actually closed "close" isn't the 3rd option. And the two commands previously suggested don't work in 2.1 thus we don't know what the value of the 3rd option really is when the lid is closed. Is there some way to write to some log file when the script runs that can be viewed later when the lid is raised????

:shock:

This works also!!

Code: Select all

#!/bin/sh
# Default acpi script that takes an entry for all actions

IFS=${IFS}/
set $@

case "$1" in
  button)
    case "$2" in
      power) /sbin/init 0    
         ;;
      lid) 
           case "$3" in     
             open) echo "!"
               ;; 
             *) /usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
               ;;
           esac 
         ;;
      *) logger "ACPI action $2 is not defined"
         ;;
    esac
    ;;
  *)
    logger "ACPI group $1 / action $2 is not defined"
    ;;
esac

case $(cat /proc/acpi/button/lid/LID/state | awk '{print $2}') in
    closed) echo -n mem >/sys/power/state
;;
esac
case $(cat /proc/acpi/button/lid/LID0/state | awk '{print $2}') in
    closed) echo -n mem >/sys/power/state
;;
esac
In terminal mode:

Code: Select all

root@porteus:/home/guest# leafpad /etc/acpi/acpi_handler.sh
root@porteus:/home/guest#  /etc/acpi/acpi_handler.sh button lid open
!
cat: /proc/acpi/button/lid/LID0/state: No such file or directory
root@porteus:/home/guest#  /etc/acpi/acpi_handler.sh button lid close
method return sender=:1.14 -> dest=:1.71 reply_serial=2
cat: /proc/acpi/button/lid/LID0/state: No such file or directory
root@porteus:/home/guest#  /etc/acpi/acpi_handler.sh button lid 
method return sender=:1.14 -> dest=:1.77 reply_serial=2
cat: /proc/acpi/button/lid/LID0/state: No such file or directory
root@porteus:/home/guest# 
But not when the lid is closed. Image
Ed

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Re: Enable suspend on lid close?

Post#40 by Ed_P » 21 Jan 2014, 17:17

This works. Image

Code: Select all

#!/bin/sh
# Default acpi script that takes an entry for all actions

IFS=${IFS}/
set $@

case "$1" in
  button)
    case "$2" in
      power) /sbin/init 0    
         ;;
      lid) 
           case $(cat /proc/acpi/button/lid/LID/state | awk '{print $2}') in
             open) echo "!"
               ;; 
             *) /usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
               ;;
           esac 
         ;;
      *) logger "ACPI action $2 is not defined"
         ;;
    esac
    ;;
  *)
    logger "ACPI group $1 / action $2 is not defined"
    ;;
esac
No idea why, but it does and that's all that counts. Image

Thanks tome, I couldn't have gotten here without you. :beer:

And you too fanthom. The fishing rod helped also. :)
Ed

tome
Contributor
Contributor
Posts: 675
Joined: 26 Jun 2013, 14:03
Distribution: x64 Openbox
Location: Russia is causing the immense damage to humanity
Contact:

Re: Enable suspend on lid close?

Post#41 by tome » 21 Jan 2014, 18:36

Is there some way to write to some log file when the script runs that can be viewed later when the lid is raised
execute this in terminal (but with default acpi_handler)

Code: Select all

sleep 3 && cat /proc/acpi/button/lid/LID/state
and close lid for 3 seconds
I think it is easier to edit '/etc/acpi/actions/lm_lid.sh' than acpi_handler.sh.
Strange behavior with this acpi script :wall:
You have mind and feelings. Be wise and clever.

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Re: Enable suspend on lid close?

Post#42 by Ed_P » 21 Jan 2014, 19:21

tome wrote:execute this in terminal (but with default acpi_handler)
I have no plans on touching this stupid file again for quite awhile. Image
I think it is easier to edit '/etc/acpi/actions/lm_lid.sh' than acpi_handler.sh.
It may be but i was never sure it was ever being used. Image

I only hope that the lid closing automatically invoking suspension gets added to 3.0 and up as a default config so we don't have to repeat this effort.



-- edit --

Someone want to add Solved to the title?
Ed

User avatar
francois
Contributor
Contributor
Posts: 6434
Joined: 28 Dec 2010, 14:25
Distribution: xfce plank porteus nemesis
Location: Le printemps, le printemps, le printemps... ... l'hiver s'essoufle.

Re: Enable suspend on lid close?

Post#43 by francois » 08 Feb 2014, 13:14

Looking for suspend on lid close for xfce, I found the command line:

Code: Select all

xfce4-power-manager-settings
Then with the gui:
On AC > actions > suspend. :)
Prendre son temps, profiter de celui qui passe.

Post Reply