View previous topic :: View next topic |
Author |
Message |
OmamoriIchika n00b
Joined: 27 Jan 2021 Posts: 61
|
Posted: Mon Mar 15, 2021 9:44 pm Post subject: Remap power button to hybrid-sleep button |
|
|
My laptop has tablet mode. A lot of time I will accidentally push the power button in tablet mode, so I want to remap power button to hybrid-sleep button using acpi. Can some check weather I’m doing right?
Code: |
$sudo nano /etc/acpi/events/power
event=button/power
action=/etc/acpi/hybridsleepsys.sh
$sudo nano /etc/acpi/hybridsleepsys.sh
#!/bin/bash
loginctl hybrid-sleep
$sudo chmod u+x /etc/acpi/hybridsleepsys.sh
$sudo rc-service acpid restart |
|
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3763 Location: Rasi, Finland
|
Posted: Thu Mar 18, 2021 10:01 pm Post subject: |
|
|
Are you using elogind or systemd? _________________ ..: Zucca :..
My gentoo installs: | init=/sbin/openrc-init
-systemd -logind -elogind seatd |
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
OmamoriIchika n00b
Joined: 27 Jan 2021 Posts: 61
|
Posted: Sat Mar 20, 2021 8:48 pm Post subject: |
|
|
Zucca wrote: | Are you using elogind or systemd? |
I use elogind.
Code: |
$sudo nano /etc/acpi/events/power
event=button/power
action=/etc/acpi/hybridsleepsys.sh
$sudo nano /etc/acpi/hybridsleepsys.sh
#!/bin/bash
[ "$2" = "PTBN" ] && exec loginctl hybrid-sleep
$sudo chmod u+x /etc/acpi/hybridsleepsys.sh
$sudo rc-service acpid restart |
I change to this, but after I push power button, it still shutdown the PC. |
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3763 Location: Rasi, Finland
|
Posted: Sun Mar 21, 2021 7:28 am Post subject: |
|
|
I think this is because elogind grabs the power button input and runs the shutdown command before your script can run.
- Edit as root your /etc/elogind/logind.conf.
- Find the line which sets HandlePowerKey.
- Change the line to: HandlePowerKey=hybrid-sleep
- Make sure that line is also uncommented (does not start with #).
- Run as root
Code: | rc-config restart elogind | !!! This will terminate your current session and take you back to login screen.
This way you don't need script to execute sleep commands. ;)
EDIT: fixed the filename from elogind.conf to logind.conf _________________ ..: Zucca :..
My gentoo installs: | init=/sbin/openrc-init
-systemd -logind -elogind seatd |
Quote: | I am NaN! I am a man! |
Last edited by Zucca on Sun Mar 21, 2021 8:22 pm; edited 1 time in total |
|
Back to top |
|
|
CaptainBlood Advocate
Joined: 24 Jan 2010 Posts: 3956
|
Posted: Sun Mar 21, 2021 8:05 pm Post subject: |
|
|
Zucca wrote: | Edit as root your /etc/elogind/elogind.conf | file not found here: Code: | sys-auth/elogind Installed versions: 246.9.2(14:40:06 19/02/2021)(pam policykit -acl -audit -debug -doc -selinux KERNEL="linux") | Any idea what I am missing?
Thks 4 ur attention, interest & support. _________________ USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. " |
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3763 Location: Rasi, Finland
|
Posted: Sun Mar 21, 2021 8:21 pm Post subject: |
|
|
CaptainBlood wrote: | Zucca wrote: | Edit as root your /etc/elogind/elogind.conf | file not found here | Oops! Indeed I wrote wrong filename. The correct one is: /etc/elogind/logind.conf _________________ ..: Zucca :..
My gentoo installs: | init=/sbin/openrc-init
-systemd -logind -elogind seatd |
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
CaptainBlood Advocate
Joined: 24 Jan 2010 Posts: 3956
|
Posted: Sun Mar 21, 2021 8:37 pm Post subject: |
|
|
Tested working after Code: | /etc/init.d/elogind restart | Thks 4 ur attention, interest & support. _________________ USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. " |
|
Back to top |
|
|
|