I would like my computer to shut down when I press the power button. Without any questioning.
First problem is, that a dialog pops up which I have to click. How to remove this?
Second problem is, that when the current user is not sudoer and anoter user is logged in on a console, my computer does not shut down. Instead the desktop user is just logged out.
Perhaps it is possible to bind the command shutdown -h now
to the power button event shomehow?
Ubuntu has a menu entry which allows you to bind keyboard events to commands. I would assume that the action triggered by the power button would also be accessible from this menu. Make a script called 'shutdown.sh' (or something) and put it in your home directory. It's contents should simply be 'shutdown -h now'. Run 'sudo chmod +x shutdown.sh' to make it executable. In a terminal, run 'sudo nano /etc/sudoers', this is will open a text file for editing. Open it with a GUI text editor by replacing 'nano' with 'leafpad', 'gedit', etc. - whatever you have installed.
Add these lines to the end of the text file:
Obviously, replace '' with your actual username. Save the changes you made (using Ctrl+o if you're using nano) Finally, configure the power button to launch your script using the Ubuntu keyboard menu. Like I said, I don;t use Unity so I am not sure of the exact procedure necessary to configure the power button to launch script, nor am I aware of the name of the key you will have to enter into the keyboard menu.
More information about editing the sudoers file can be found here: Ubuntu Sudoers