Page 2 of 3

Re: Enable suspend on lid close?

Posted: 13 Jan 2014, 04:50
by Ed_P
tome wrote:Ed_P
maybe you should create launcher for suspend and eventually assign some keys to execute this, you can see also: forum.porteus.org/viewtopic.php?f=39&t=2839
I tried the steps shown in your link to create a Hibernate icon on my desktop. But it doesn't work for me. :( The desktop icon has no name under it and dbl clicking on it does nothing.

I used the hibernate code posted on the link, named the file Hibernate.desktop and located it in my /home/guest/desktop folder. I assumed that was what you meant when you said "Create new choose -name.desktop file on your desktop".

Thoughts?

Re: Enable suspend on lid close?

Posted: 13 Jan 2014, 06:23
by tome
if you want hibernate you need swap partition or file, try suspend. You can also change Name= and Icon= parameters if you need some other for your qt desktop.

Re: Enable suspend on lid close?

Posted: 14 Jan 2014, 00:37
by Ed_P
I changed the name of the file from Hibernate.desktop to just Hibernate. This resulted in the name Hibernate appearing under the icon on the desktop, the icon changing to a page from a spiral notebook and dbl clicking on the icon opening the text in Firefox.

Something isn't right.

Re: Enable suspend on lid close?

Posted: 14 Jan 2014, 06:10
by Ed_P
fanthom wrote:i have given you a fishing rod and not a fish itself. dont be lazy and read linked doc then create proper action in your /etc/acpi/acpi_handler.sh file.
I tried both commands in 1st link, the 1st command, journalctl -f, did nothing regardless which keys I tried and the only way I could exit it was to restart LXTerminal. The 2nd command produced an error:

Code: Select all

guest@porteus:~$ su
Password: 
root@porteus:/home/guest# acpi_listen
acpi_listen: can't open socket /var/run/acpid.socket: Connection refused
root@porteus:/home/guest# 
In reviewing this link it refers to files in /etc/acpi/events and /etc/acpi/actions folders. In the RazorQT system there exist files that appear to address the lid shutdown situation, lm_lid and lm_lid.sh. And the lm-lid.sh file appears to be set to run a file named laptop_mode which is in the /usr/sbin folder.

So doesn't this mean that code to handle the closing of the lid is already present but not working?

Re: Enable suspend on lid close?

Posted: 14 Jan 2014, 23:17
by tome
Ed_P
in Spacefm execute Hibernate.desktop by right clicking on it and execute, or move this file to /home/guest/.local/share/applications or /usr/share/applications

Re: Enable suspend on lid close?

Posted: 15 Jan 2014, 07:31
by Ed_P
tome wrote:in Spacefm execute Hibernate.desktop by right clicking on it and execute,
Ok, I replaced the Hibernate file with one name Suspend, since you said Hibernate required a file. With the file named Suspend right clicking on it in SpaceFM does not have Execute as an option. I renamed the file to be Suspect.desktop, then the desktop icon changed to a gear but the label under the icon became blank. However,
right clicking on it in SpaceFM does have the Execute option. Selecting Execute opens an Error window stating Command not found.

The other two files in the /home/guest/Desktop/ folder, Home and System, do not have .desktop appended to their names but do have Execute option when right clicking on them.

Re: Enable suspend on lid close?

Posted: 17 Jan 2014, 09:27
by tome
tested in Razor fresh mode and it works so go to:https://www.dropbox.com/sh/ui4ydoh3j34x ... /launchers download suspend.desktop to your desktop (eventually change permissions - right mouse button -> Properties -> Permissions and set similar to home.desktop shortcut) and try.
You can also try

Code: Select all

/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
in terminal.

Re: Enable suspend on lid close?

Posted: 17 Jan 2014, 22:44
by Ed_P
Wow!! tome it works!! :Yahoo!: Both before and after the permission changes and in terminal mode. :beer:

Code: Select all

guest@porteus:~$ /usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
method return sender=:1.14 -> dest=:1.22 reply_serial=2
guest@porteus:~$ su
Password: 
root@porteus:/home/guest# leafpad /etc/acpi/acpi_handler.sh
I also tried it in the /etc/acpi/acpi_handler.sh file with somewhat strange results.

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) /usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
         ;;
      *) logger "ACPI action $2 is not defined"
         ;;
    esac
    ;;
  *)
    logger "ACPI group $1 / action $2 is not defined"
    ;;
esac
I close the lid and the system suspends just like when I click on the desktop icon. I open the lid and reactivate the system, it activates and then 2 seconds later re-suspends!! Image I re-activate again and it's fine. Do not understand the secondary suspension,

Re: Enable suspend on lid close?

Posted: 18 Jan 2014, 18:48
by Ed_P
Image journalctl -f doesn't work under 3.0 rc1 either. But acpi_listen does. Image

Code: Select all

guest@porteus:~$ acpi_listen
button/lid LID close
button/lid LID open
Unfortunately my acpi_handler.sh code change doesn't work.

Code: Select all

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

I tried if [ "$2" != "open" ]; also but it didn't work either. :wall:

Re: Enable suspend on lid close?

Posted: 19 Jan 2014, 16:40
by tome
For previous (default) acpi_handler.sh (or for '/etc/acpi/actions/lm_lid.sh') add at end this:

Code: Select all

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

Re: Enable suspend on lid close?

Posted: 20 Jan 2014, 05:37
by Ed_P
tome wrote:For previous (default) acpi_handler.sh (or for '/etc/acpi/actions/lm_lid.sh') add at end this:

Code: Select all

case $(cat /proc/acpi/button/lid/LID/state | awk '{print $2}') in
    closed) echo -n mem >/sys/power/state
;;
esac
This isn't working for me tome.

Code: Select all

#!/bin/sh
# Default acpi script that takes an entry for all actions
# /etc/acpi/
#
# Modified by Ed_P 1/20/14 to support auto suspend when lid closed
# using command provided by @tome. 
# http://forum.porteus.org/viewtopic.php?f=81&t=3018&p=21384#p21384

IFS=${IFS}/ 
set $@

case "$1" in
  button)
    case "$2" in
      power) /sbin/init 0
         ;;
      *) 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

Re: Enable suspend on lid close?

Posted: 20 Jan 2014, 05:51
by tome
go to
/proc/acpi/button/lid/
or similar, find and add correct path for state to this script

Re: Enable suspend on lid close?

Posted: 20 Jan 2014, 06:15
by Ed_P
/proc/acpi/button/lid/LID/state

Code: Select all

state:      open

Re: Enable suspend on lid close?

Posted: 20 Jan 2014, 18:19
by tome
Try this (replaced LID with LID0):

Code: Select all

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

Re: Enable suspend on lid close?

Posted: 20 Jan 2014, 18:45
by Ed_P
No effect.