allow to set restart/resume time in shutdown dialog

Bug #987664 reported by ceg
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Shutdown Timer Extension for GNOME shell
New
Undecided
Unassigned
consolekit (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

The desktop environments would help saving energy, if their shutdown dialogs could by default provide the option (button/checkbox) to schedule a restart.

Linux provides a simple way to schedule a restart event that is particularly usefull in conjuction with initiating or scheduling a shutdown or suspend.

rtcwake -m no -s <seconds-util-start-event>

Howerever, just as the shutdown command it requires root privileges. Thus the need for a similar consolekit support.

The particular command given in the example above avoids that rtcwake does any switching into another power state (no new mode "-m no").
This allows that all power state switching is still contolled by whatever power management (userspace) tools are installed, which may often be more stable than the pure kernel/rtcwake method, especially on resume.

To test it, just schedule a wake event like above as root, then do a regular shutdown/suspend. Wait, and watch how the real time clock triggers the scheduled power up event and the machine comes back up.

Revision history for this message
hakaishi (hakaishi) wrote :

Hmm... So you would like to have an option or something like that for qshutdown?
The problem is that qshutdown usually is used by users without admin rights and rtcwake seems to need these rights...
So there are two solutions: add the user or group you want to the sudoers for rtcwake and enter the commands in the advanced settings (aviable from version 1.6.4 on. Upload to Debian and the Launchpads PPA on 29th April) for qshutdown, or make a little script that first executes your rtcwake command and then starts qshutdown. You'll either need to add the user to the sudoers, or start the script and let it first ask for the password with gksudo or something like that.
I hope to have shed a bit light to the problem. :)

Revision history for this message
ceg (ceg) wrote :

Thanks for the hint!

Actually, doesn't triggering a shuting down also require root privileges? What framework/application provides this functionallity to user space? Maybe it could do the same for start events?

description: updated
Revision history for this message
hakaishi (hakaishi) wrote :

That's right. "shutdown" and "reboot" etc. need root privileges.
But there ist also a complicated way to do this via dbus-send. With this also the user can suspend/hibernate/reboot/shutdown. For this there is ConsoleKit and gnome.SessionManager aviable.
For a direct shutdown (without prompt) there is only one way that I know of: "dbus-send --print-reply --system --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop"
Previously there was also a way to "correctly" shutdown the system (not that it is a unclean shutdown, but the session can not be saved before shutdown, even if one has set "Save Session") via org.gnome.SessionManager, but one of it's methods have been removed - and I'm still wondering why...

With introspect one can see all the aviable methods etc. for the interface. (e.g. "dbus-send --print-reply --system --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.DBus.Introspectable.Introspect")
And I haven't noticed something about a wake-up method/option... :'(

Revision history for this message
ceg (ceg) wrote :

Thank you for the pointer to ConsoleKit.

Do I understand it correctly, there is no way to initiate a shutdown in gnome that saves the session, without using the gnome-session buttons?

(I have been disapointed by gnome folks dumbing down functionality in other areas already,
they are not just providing easy options plus expert settings, but really removing options,
maybe it is time I remove gnome.)

ceg (ceg)
description: updated
description: updated
Revision history for this message
hakaishi (hakaishi) wrote :

Jep, that's how it seems to be...
But you just gave me a nice idea! I'll research how gnome saves the session and put the command just before the execution of dbus-send ... that means if the command can be executed by the user. (Of course with an option to aktivate/deaktivate this)

You are right. I'm also quite dissapointed in how gnome does things...

... Well it's still better than Unity >_>"

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in consolekit (Ubuntu):
status: New → Confirmed
Revision history for this message
hakaishi (hakaishi) wrote :

Woooha! I'm really amazed! => http://www.linux-archive.org/ubuntu-desktop/478109-gnome-session-saving-dropped-natty.html
I guess they won't make the feature aviable by default for the next coming releases as well...

Revision history for this message
hakaishi (hakaishi) wrote :

*available

Revision history for this message
Jacopo Lorenzetti (jacopol) wrote :

GNOME Session Shutdown can trigger a shutdown from user space via dbus. Its syntax is similar to that of the 'shutdown' command (e.g. 'gnome-session-shutdown -P +30') but it doesn't need root privileges.

I wrote it because I needed to programmatically shut down the system in a clean fashion (instead of just terminating the GNOME Display Manager like the 'shutdown' command does) and I couldn't find a way to do it.

I don't know about start events, sorry.

Changed in gnome-session-shutdown:
status: New → Invalid
Revision history for this message
hakaishi (hakaishi) wrote :

Does your shutdown() funktion shutdown without showing the shutdown dialog? - If so, could you please tell me where the imported file imports.misc.gnomeSession lies?

Revision history for this message
Jacopo Lorenzetti (jacopol) wrote :

It does show the shutdown dialog for 60 seconds (that is your last chance to cancel the shutdown) and then it shuts the system down.

Revision history for this message
hakaishi (hakaishi) wrote :

I knew it... >_>"
There is still the bug that the methods of the gnome.SessionManager interface namely "Shutdown" and "RequestShutdown" do the same, while one of them should shutdown without showing that dialog... I already filed a bug because of this, but nobody cares ... => https://bugs.launchpad.net/ubuntu/+source/gnome-session/+bug/931565

Revision history for this message
ceg (ceg) wrote :

Hi jacopoL, you set this to invalid, because you don't know about start events?

Revision history for this message
Jacopo Lorenzetti (jacopol) wrote :

I'm not sure about the older versions, but on my Ubuntu 12.04 they don't do the same: Shutdown shows the dialog with a 60-seconds countdown and RequestShutdown doesn't show any dialog.

GNOME Session Shutdown calls the first method because I liked the idea to have one last chance to cancel the shutdown… maybe I could add an option to let the user choose.

Revision history for this message
Jacopo Lorenzetti (jacopol) wrote :

ceg: I set it to invalid because GNOME Session Shutdown is something like a GNOME high-level equivalent of the 'shutdown' command, and I think that you are looking for some different kind of multipurpose tool… or maybe something to call just before gnome-session-shutdown (command line) or qshutdown (GUI). Or have I misunderstood something?

Revision history for this message
hakaishi (hakaishi) wrote :

jacopoL: Just a second. Did you acually test that? For me both RequestShutdown and Shutdown call the shutdown dialog on Ubuntu 12.04, using gnome-shell. I tested it on my Computer and on my Netbook. Did you by chance add any parameters or something?

Revision history for this message
ceg (ceg) wrote :

I don't know how all the desktop parts work together. However, it is a waste of resources to let your computer run only because for example you need to access it remotely in a couple of hours/days/month, or have it do some task. And I see many user that keep their machines running, just because they do not see a way to schedule it.

The desktop environments would help saving energy, if their shutdown dialogs could by default provide the option (button/checkbox) to schedule a restart.

ceg (ceg)
description: updated
Revision history for this message
hakaishi (hakaishi) wrote :

OKAY! Now I know a way to make qshutdown execute multiple commands (using &&). In the coming new version this will be possible. Then you can just put sudo or gksudo or what ever before the command and that's it. If you want that there is no prompt for a password, just add the command to the sudoers disabling the Password. ;)

Revision history for this message
Jacopo Lorenzetti (jacopol) wrote :

hakaishi: I actually tested that in python by connecting to the dbus session bus and calling the two methods (without parameters) on the org.gnome.SessionManager interface. I'm running Unity on Ubuntu 12.04. If you need me to test something in particular about that or if you need more info about my configuration, feel free to drop me a line.

Revision history for this message
hakaishi (hakaishi) wrote :

And there I thought that I could get qshutdown to take multiple commands... It actually froze up qshutdown and that shouldn't be... I still hope to finde another solution from Qt.

jacopoL: Yes, I can confirm that the dbus commands work the way they should when one uses Unity. What the heck? - Stupid gnome-shell >_<"
By the way, when using Debian (Testing) and gnome-shell there is no RequestShutdown method. (confirmed via "dbus-send --print-reply --session --dest=org.gnome.SessionManager /org/gnome/SessionManager org.freedesktop.DBus.Introspectable.Introspect")

Revision history for this message
hakaishi (hakaishi) wrote :

I finally got qshutdown to accept "&&". One can now define for eg. something like "shutdown -P now && rtcwake -m on -s 60" or any other commands. The new PPA is now uploaded and waits to be build. It will be aviable from Hardy till Precise. For Quantal it will be included via Debian, but that will take some time.

ceg (ceg)
description: updated
summary: - allow to set restart/resume time
+ allow to set restart/resume time in shutdown dialog
description: updated
no longer affects: gnome-session-shutdown
no longer affects: xfdesktop4 (Ubuntu)
hakaishi (hakaishi)
no longer affects: qt-shutdown-p
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.