You are not logged in.
Pages: 1
Hello guys,
I'm looking for a way to turn off my laptop as normal user by pressing the power button without the need of using "sudo shutdown -h now".
The only alternative I know about is dbus/console-kit but as this method obviously uses HAL I'm looking for another (I don't like HAL dependecies *g*).
Suggestions?
Best regards
orschiro
Offline
If you don't want to sudo, add yourself to the power group.
For using the laptop power button, I think you need ACPI.
Last edited by Berticus (2010-05-22 20:07:05)
Offline
If I remember well it is stated in the wiki. That you should add your user to the group power and you might have to change the permission of the group for shutdown and halt so they could execute it.
So chmod g+x whatever or chown root:power something.
Last edited by lymphatik (2010-05-22 20:09:11)
Offline
sudo visudo
Offline
%sleep ALL=NOPASSWD: /sbin/reboot
%sleep ALL=NOPASSWD: /sbin/halt
Thats what I did, and I made the group %sleep and added any users to that group and then they can sudo halt and the computer will shutdown but then their sudo wont work for anything else
Offline
Hello guys,
so when using a seperate power group and chown /sbin/shutdown to it then I could also directly chmod it isn't it?
chmod u+s /sbin/shutdown
Is there any disadvantage by doing this?
EDIT:
I tried also the power group method, added my user to power and then chowned via "chown root:power /sbin/shutdown", logged in again, but I still get the message that I have to be root.
What's wrong?
Do I have to change file permissions?
-rwxr-xr-x 1 root power 23840 1. Mai 2009 shutdown
Last edited by orschiro (2010-05-22 21:58:19)
Offline
Are you in the power group? I know its a dumb question but you never know.
Offline
I just hold mine down to power off. I would never dare set it to shut down just from a single press for the fear of someone coming up from behind and pressing it as a joke.
Offline
You should look into changing the acpi behavior. Specifically, look at /etc/acpi/handler.sh
This is how I handle sleeping when the lid closes. This is most likely how you should be handling the behavior you want. This is also probably a bit smarter, in that you don't need to open up any privileges to non-root users.
For example, for sleeping I added /etc/acpi/sleep.sh to the button/lid) section.
button/lid)
/etc/acpi/sleep.sh
sleep.sh contains
#!/bin/sh
sleep 1
if grep -q open /proc/acpi/button/lid/LID/state; then
exit 0;
fi
s2ram -f
And this is I THINK the correct way to handle such things.
So you should add a line to
button/power)
which if you just want to shutdown could be "halt" (this is the same as shutdown -h now)
Hopefuly that is somewhat helpful.
Offline
I just hold mine down to power off.
You do know that is exactly how you force the power supply to shut down regardless of whether the operating system is ready or not?
Pushing it once is a request, in response the OS should initiate a shutdown sequence which ends with all of the disks left in a clean state. After it is ready, the OS sends a message to the power supply that it may now remove power. This is the process eloquently described by measure.
Pushing and holding is used for when the OS has gone Tango-Uniform and won't or can't initiate the shutdown. This is equivalent to just pulling the plug, and is likely to result in corrupted file systems.
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
Hello guys,
I looked a bit deeper into acpid and it really seems the recommended way to handle those tasks.
I configured it and it's running fine now.
Nevertheless one daemon more that has to run.
Offline
Pages: 1