You are not logged in.
I have written a little program which is supposed to execute "poweroff" system command (system("poweroff")) after the delay which has been set previously (by input). Unfortunaly, if the program is not ran by root, I get this error after the countdown is done:
poweroff: must be superuser.I noticed 'poweroff' requires root privilegies, but I wonder how, if I'm logged in to MATE DE as user, I can still shutdown system from MATE's menu.
Another example: qBittorrent can also shutdown the system even if it's ran as user.. by enabling "Autoshutdown on downloads completion" option.
What "trick" do they use?
Thank you.
Last edited by broi (2012-09-28 19:47:03)
Offline
You should look into sending the proper signal to upower via dbus. This is how I used to shutdown and reboot from my openbox menu anyway. That way, you should be able to issue poweroff with your users priveliges.
Offline
You should look into sending the proper signal to upower via dbus. This is how I used to shutdown and reboot from my openbox menu anyway. That way, you should be able to issue poweroff with your users priveliges.
Thank you very much for appointing me to dbus/power. After very little search of those I found this topic helpfull:
https://bbs.archlinux.org/viewtopic.php?id=127962
and the ArchWiki:
https://wiki.archlinux.org/index.php/Co … operations
Inside C++ source:
..
system("dbus-send --system --print-reply --dest=""org.freedesktop.ConsoleKit"" /org/freedesktop/ConsoleKit/Managerorg.freedesktop.ConsoleKit.Manager.Stop");
...Solved.
Last edited by broi (2012-09-28 19:46:16)
Offline