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):
Normally there is an «End» key (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.
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):
First of all, set action of "Power Off" button to
nothing
.Unity
Like mentioned in answer of Johano Fierra:
or alternatively
sudo apt install dconf-tools
and usedconf-editor
to changeorg.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.
Install xdotool:
This one will allow us to trigger key events.
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:and create
/etc/acpi/power.sh
script with the following contents:and add execution permissions to it:
Ubuntu 16.04
Backup ACPI script used to handle "Power Off" button's event:
Then edit it, find the following:
and modify the code below so it looks like:
In order to apply these changes one should run:
Thanks to Adam it's possible to restart
acpid
automatically when a user logs in (on system boot). So instead of manualsudo acpid restart
in terminal each time after reboot add the following line:to the end of
/etc/pam.d/common-session
file.This should do the trick.
Enter in terminal: