UPower for regular users
Major desktop environments usually provide a user-friendly menu to suspend your computer. Internally, if seems to use something called UPower, which uses something called PolicyKit, which in turn may or may not use another piece called ConsoleKit (do not ask me what all these pieces are and how they relate to each other, I do not know and I do not want to know). For the regular user, the result is the following: when they click on that button, it suspends their computer.
UPower for command line users
However, if you are using a more unusual desktop environment, for instance a simple, light window manager, you will not have such a button. And no, UPower does not provide a simple command line tool to suspend your computer¹ (they probably consider that command line is out of fashion…). Well, in case you need it, here is a way to suspend your computer from a command line or whatever: just alias it or bind it to a key shortcut. It uses some dark DBus magic:
$ dbus-send --system --print-reply --dest='org.freedesktop.UPower' \ /org/freedesktop/UPower org.freedesktop.UPower.Suspend
If you prefer to hibernate your computer, that is, to suspend it, not to RAM but to disk:
$ dbus-send --system --print-reply --dest='org.freedesktop.UPower' \ /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
As you can see, for some reason it requires some duplication of information: the name “org.freedesktop.UPower” appears three times in that command line: in the “destination”, “object path” and “interface member”, whatever that could mean. Again, do not ask me why, I know nothing about that and I do not want to.
Notes
- Actually, UPower does provide a command line tool called upower, but the only thing it does (monitoring power sources) is not really useful for that matter. ↑
12 comments
tuesday 05 march 2013 à 13:02 Pev said : #1
tuesday 05 march 2013 à 13:50 gregoa said : #2
tuesday 05 march 2013 à 14:30 foo said : #3
tuesday 05 march 2013 à 17:11 mbiebl said : #4
tuesday 05 march 2013 à 17:22 Joey Hess said : #5
tuesday 05 march 2013 à 17:50 Tanguy said : #6
tuesday 05 march 2013 à 18:27 Paul Menzel said : #7
tuesday 05 march 2013 à 18:53 Manuel Pégourié-Gonnard said : #8
tuesday 05 march 2013 à 21:58 Anonymous said : #9
wednesday 06 march 2013 à 10:21 Philipp Kern said : #10
wednesday 06 march 2013 à 13:12 mirabilos said : #11
wednesday 06 march 2013 à 23:18 Anonymous said : #12