Score:0

Disable shutdown confirmation for physical "Power off" button in the dash (Ubuntu 20.04)

it flag

On my notebook in the dash (above the keyboard) there is physical button for turning the computer on and off.

How to set up this button to turn off the system immediately without confirmation? Where is the handler for this button? Or how to create it and use? I want to put to it systemctl poweroff.

There is the similar question - Disable shutdown confirmation ubuntu 20.04 but it is not only about setting up the physical "Power off" button. For configuring Shutdown/Reboot menu items in system menu Bring Out Sub Menu Extension can be used as explained here. Moreover the accepted answer in this question is not working - I tried it. Also this answer explains that the solution must be another.

Please do not suggest to me:

  • To press to the button and wait a minute.
  • To make keyboard shortcut.

I have "Power button" and I want to make use of it. Or at least to know that this is impossible in Ubuntu 20.04.

Score:1
id flag

For GNOME Desktop, in your terminal run

hostnamectl set-chassis vm

then reboot. After the system reboots it should work where the power button will now power off the system without asking.

To set it back run

hostnamectl set-chassis desktop

same as above, reboot the system then it should start asking again about shutting down.

Hope this helps!

it flag
Terrance, thanks. I just tested everything in your answer and confirm that all works as you described (only not tested for the second user). Thanks for the solution! I'm curious what command gets executed under this `VM chassis mark` to reboot the system? And where this command is configured? May it can be customized?
Score:0
it flag

First solution

I found working solution here and here:

  • Create file:

sudo nano /etc/acpi/events/powerbtn

with the content:

event=button/power (PWR.||PBTN)
action=/sbin/poweroff
  • Then restart the acpi daemon with:

sudo acpid restart

  • Try to use "Power off" button.

Related links:


Second solution

Also I tested the answer of Terrance and confirm that this recommendations is also working.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.