Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Kernel & Hardware
  • Search

Remap power button to hybrid-sleep button

Kernel not recognizing your hardware? Problems with power management or PCMCIA? What hardware is compatible with Gentoo? See here. (Only for kernels supported by Gentoo.)
Post Reply
Advanced search
7 posts • Page 1 of 1
Author
Message
OmamoriIchika
n00b
n00b
Posts: 61
Joined: Wed Jan 27, 2021 2:28 pm

Remap power button to hybrid-sleep button

  • Quote

Post by OmamoriIchika » Mon Mar 15, 2021 9:44 pm

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: Select all

$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
Top
Zucca
Administrator
Administrator
User avatar
Posts: 4706
Joined: Thu Jun 14, 2007 10:31 pm
Location: Rasi, Finland
Contact:
Contact Zucca
Website

  • Quote

Post by Zucca » Thu Mar 18, 2021 10:01 pm

Are you using elogind or systemd?
..: Zucca :..

Code: Select all

0100100100100000011000010110110100100000
0100111001100001010011100010000100100000
0100100100100000011000010110110100100000
0110000100100000011011010110000101101110
00100001
Top
OmamoriIchika
n00b
n00b
Posts: 61
Joined: Wed Jan 27, 2021 2:28 pm

  • Quote

Post by OmamoriIchika » Sat Mar 20, 2021 8:48 pm

Zucca wrote:Are you using elogind or systemd?
I use elogind.

Code: Select all

$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.
Top
Zucca
Administrator
Administrator
User avatar
Posts: 4706
Joined: Thu Jun 14, 2007 10:31 pm
Location: Rasi, Finland
Contact:
Contact Zucca
Website

  • Quote

Post by Zucca » Sun Mar 21, 2021 7:28 am

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: Select all

    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
Last edited by Zucca on Sun Mar 21, 2021 8:22 pm, edited 1 time in total.
..: Zucca :..

Code: Select all

0100100100100000011000010110110100100000
0100111001100001010011100010000100100000
0100100100100000011000010110110100100000
0110000100100000011011010110000101101110
00100001
Top
CaptainBlood
Advocate
Advocate
User avatar
Posts: 4237
Joined: Sun Jan 24, 2010 9:38 am

  • Quote

Post by CaptainBlood » Sun Mar 21, 2021 8:05 pm

Zucca wrote:Edit as root your /etc/elogind/elogind.conf
file not found here:

Code: Select all

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. "
Top
Zucca
Administrator
Administrator
User avatar
Posts: 4706
Joined: Thu Jun 14, 2007 10:31 pm
Location: Rasi, Finland
Contact:
Contact Zucca
Website

  • Quote

Post by Zucca » Sun Mar 21, 2021 8:21 pm

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 :..

Code: Select all

0100100100100000011000010110110100100000
0100111001100001010011100010000100100000
0100100100100000011000010110110100100000
0110000100100000011011010110000101101110
00100001
Top
CaptainBlood
Advocate
Advocate
User avatar
Posts: 4237
Joined: Sun Jan 24, 2010 9:38 am

  • Quote

Post by CaptainBlood » Sun Mar 21, 2021 8:37 pm

Tested working after

Code: Select all

/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. "
Top
Post Reply

7 posts • Page 1 of 1

Return to “Kernel & Hardware”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic