LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-12-2019, 07:18 AM   #1
coralfang
Member
 
Registered: Nov 2010
Location: Bristol, UK
Distribution: Slackware, FreeBSD
Posts: 748
Blog Entries: 3

Rep: Reputation: 233Reputation: 233Reputation: 233
Change behaviour of power button to suspend/hibernate?


Hi. If i press my power button on the PC case, shutdown immediately starts. What's the best way to change that to suspend/hibernate in slackware?

Instead of manually running;

Code:
# /usr/sbin/pm-hibernate
or

Code:
# /usr/sbin/pm-suspend
How would i run one of those commands when the power button is pressed?

IF i were to take a guess; it's managed by /etc/acpi/acpi_handler.sh ? If i were to change the line where it states /sbin/init 0 to one of those pm-* commands, this will do the job correct? Thought i'd ask first in case i break something.
 
Old 06-12-2019, 07:30 AM   #2
Lysander666
Senior Member
 
Registered: Apr 2017
Location: The Underearth
Distribution: Slackware
Posts: 1,588
Blog Entries: 3

Rep: Reputation: 1595Reputation: 1595Reputation: 1595Reputation: 1595Reputation: 1595Reputation: 1595Reputation: 1595Reputation: 1595Reputation: 1595Reputation: 1595Reputation: 1595
What desktop environment? I have mine set up through the Power Management settings in Xfce.
 
Old 06-12-2019, 07:31 AM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware 14.2 current / ArcoLinux / Void Linux
Posts: 8,650

Rep: Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797
what desktop are you using? Some have within there (power) settings this capability to tell the system what to do when you press the power button. You just need to merely select it.
 
Old 06-12-2019, 07:32 AM   #4
Lysander666
Senior Member
 
Registered: Apr 2017
Location: The Underearth
Distribution: Slackware
Posts: 1,588
Blog Entries: 3

Rep: Reputation: 1595Reputation: 1595Reputation: 1595Reputation: 1595Reputation: 1595Reputation: 1595Reputation: 1595Reputation: 1595Reputation: 1595Reputation: 1595Reputation: 1595
Damn that was close, BW.
 
Old 06-12-2019, 07:37 AM   #5
coralfang
Member
 
Registered: Nov 2010
Location: Bristol, UK
Distribution: Slackware, FreeBSD
Posts: 748

Original Poster
Blog Entries: 3

Rep: Reputation: 233Reputation: 233Reputation: 233
I'm using AwesomeWM mostly, so no Desktop environment. But i'd also like to be able to suspend/hibernate when X isn't running too.
 
Old 06-12-2019, 08:06 AM   #6
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 1,491

Rep: Reputation: 1111Reputation: 1111Reputation: 1111Reputation: 1111Reputation: 1111Reputation: 1111Reputation: 1111Reputation: 1111Reputation: 1111
You want to use /etc/acpi/acpi_handler.sh for that. Make it executable and use something like this:

Code:
case "$1" in
  button)
    case "$2" in
      power)
        /usr/sbin/pm-suspend
        ;;
...
 
Old 06-12-2019, 10:12 AM   #7
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 5,192

Rep: Reputation: 1853Reputation: 1853Reputation: 1853Reputation: 1853Reputation: 1853Reputation: 1853Reputation: 1853Reputation: 1853Reputation: 1853Reputation: 1853Reputation: 1853
Personally, I think that intercepting the power button for this is a bad idea. It could make it difficult to recover from a runaway situation.
If the desktop environment/window manager does not handle this natively, then I suggest installing xbindkeys and mapping a key combination to run pm-hibernate or pm-suspend when within X.
At the command line, I suggest setting up an alias to shorten the typing required.
 
1 members found this post helpful.
Old 06-12-2019, 10:25 AM   #8
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware 14.2 current / ArcoLinux / Void Linux
Posts: 8,650

Rep: Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797
Quote:
Originally Posted by Lysander666 View Post
Damn that was close, BW.
yeah i was typing when you posted, seen yours after I posted, so I just left it as is.
 
Old 06-12-2019, 10:29 AM   #9
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware 14.2 current / ArcoLinux / Void Linux
Posts: 8,650

Rep: Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797Reputation: 1797
here is something on systemD and dealing with that in i3 but it is being controlled by the system and not the WM so... maybe applicable.

https://www.reddit.com/r/i3wm/commen..._avoid_brutal/
Quote:
Originally Posted by post
level 1
OneTurnMore
i3-gaps15 points
2 years ago

The power button isn't handled by the window manager, it's handled by systemd

For example this is in my /etc/systemd/logind.conf

[Login]
HandlePowerKey=hibernate
HandleLidSwitch=ignore
IdleAction=suspend
IdleActionSec=20min

i3 doesn't do power-management on it's own. I have used xfce4-power-manager in the past. (Use xfce4-power-manager-settings to edit settings.)

Last edited by BW-userx; 06-12-2019 at 10:30 AM.
 
Old 06-13-2019, 05:05 PM   #10
Tonus
Member
 
Registered: Jan 2007
Location: Paris, France
Distribution: Slackware-current
Posts: 481
Blog Entries: 3

Rep: Reputation: 131Reputation: 131
Change behaviour of power button to suspend/hibernate?

In i3wm I've got these commands bind to shortcuts (as in kdeconnect) :

Code:
 
dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
You might want to lock before that otherwise your laptop would be unlocked when woke up.

Beware also, if you have the lock in the shortcut, don't use && from kdeconnect : if the screen is already locked, command will fail and abort (I use a sleep XXXX && hibernate command often to have a bit music when going to bed...).

Last edited by Tonus; 06-13-2019 at 05:10 PM.
 
  


Reply

Tags
button, hibernate, power, suspend


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Non standard Hibernate & Suspend behaviour business_kid Linux - Laptop and Netbook 0 08-30-2011 10:50 AM
gnome-power-manager Suspend / Hibernate problem Robhogg Debian 1 11-04-2008 05:51 PM
Hibernate / Suspend Not Working - Gnome Power Manager ls37 Linux - Newbie 5 12-30-2007 01:14 PM
Power Saving Modes (Hibernate vs Suspend) carlosinfl Linux - General 3 06-29-2007 09:19 AM
hibernate, suspend, is it safe to unplug mains power when battery in? lugoteehalt Linux - Laptop and Netbook 8 03-08-2007 07:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration