Wednesday, May 8, 2024
 Popular · Latest · Hot · Upcoming
12
rated 0 times [  12] [ 0]  / answers: 1 / hits: 6770  / 3 Years ago, fri, september 17, 2021, 7:03:06

I've bought the ROG G551JM Asus laptop which proven to be Ubuntu-compatible. The computer's keyboard is ill-designed with the key "Poweroff" being an ordinary key, placed in the spot, where one usually finds the "End" key. The computer is fine otherwise, so I bought it with the assumption, that I would be able to somehow "fix" the problem, i.e. remap the PowerOff button into the "End" key.



The PowerOff button made wrong (ASUS G551JM):
ASUS G551JM



Normally there is an «End» key (ASUS N56VZ):
ASUS N56VZ



The "PowerOff" button events are produced by the /dev/input/event2: Power Button device (as reported by evtest) with code 116 (example line from evtest: Event: time 1422895638.246142, type 1 (EV_KEY), code 116 (KEY_POWER), value 1)



The key is also visible to X server, and ultimately Ubuntu can identify key presses as a PowerOff key and launches the "Goodbye user Adam..." semi-transparent dialog box that confirms my will to actually turn the computer off.



The problem is that the binding that binds the PowerOff key press with the routine that displays that confirmation dialog is not visible under dconf-editor and I have no hint where to find it.



Can anyone tell me, where to change (or delete) the default binding for the PowerOff key???



It should be something easy.






edit 21.IX.2016:



There is a way to permanently disable the dialog box, see How do I modify the options for the power button? . I hope that after disabling the power button, it would be possible to re-assign it to something else.


More From » 14.04

 Answers
3

I was able to get it working on my ASUS N751JK in Ubuntu 18.04 LTS and Ubuntu 16.04 LTS (tested with Unity desktop environment in both cases and KDE Plasma in 18.04):




  1. First of all, set action of "Power Off" button to nothing.



    Unity



    Like mentioned in answer of Johano Fierra:



    gsettings set org.gnome.settings-daemon.plugins.power button-power "nothing"


    or alternatively sudo apt install dconf-tools and use dconf-editor to change org.gnome.settings-daemon.plugins.power property (like described here). Reboot or logout is required to make it working.



    KDE



    Go to "System Settings", select "Power Management" tab in "Hardware" section and then select "Energy Saving" tab, scroll down, find "When power button pressed" dropdown list and change its value to "Do nothing". Click "Apply" button for changes to take an effect.



    Energy saving


  2. Install xdotool:



    sudo apt install xdotool


    This one will allow us to trigger key events.


  3. Next step is to trigger "End" key press on "Power off" button press.



    Ubuntu 18.04



    Create /etc/acpi/events/power file with the following contents:



    event=button/power
    action=/etc/acpi/power.sh "%e"


    and create /etc/acpi/power.sh script with the following contents:



    #!/bin/sh
    xdotool key End


    and add execution permissions to it:



    sudo chmod +x /etc/acpi/power.sh


    Ubuntu 16.04



    Backup ACPI script used to handle "Power Off" button's event:



    sudo cp /etc/acpi/powerbtn.sh /etc/acpi/powerbtn.sh.backup


    Then edit it, find the following:



    # If logind is running, it already handles power button presses; desktop
    # environments put inhibitors to logind if they want to handle the key
    # themselves.


    and modify the code below so it looks like:



    if pidof systemd-logind >/dev/null; then
    xdotool key End
    exit 0
    fi

  4. In order to apply these changes one should run:



    sudo acpid restart


    Thanks to Adam it's possible to restart acpid automatically when a user logs in (on system boot). So instead of manual sudo acpid restart in terminal each time after reboot add the following line:



    session optional    pam_exec.so /usr/sbin/acpid restart


    to the end of /etc/pam.d/common-session file.



[#21463] Saturday, September 18, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lassrake

Total Points: 400
Total Questions: 103
Total Answers: 98

Location: Netherlands
Member since Mon, Jun 22, 2020
4 Years ago
;