Suspend my laptop by Command

Suspend my laptop by Command

Suspend my laptop by Command

I upgrade my fedora desktop to fedora18, and get some trouble after upgrade. One of them is that my old script to suspend my laptop do not works anymore(I like to suspend my laptop without close its screen lid.) .

My old script to suspend the PC:
#!/bin/bash

dbus-send --system --print-reply --dest=org.freedesktop.Hal \
     /org/freedesktop/Hal/devices/computer \
      org.freedesktop.Hal.Device.SystemPowerManagement.Suspend \
       int32:0

Table of Contents

  • 1 Why HAL dbus interface did not works
  • 2 Two ways to Suspend/Hibernate the Laptop

1 Why HAL dbus interface did not works

The reason is that HAL(Hardware Abstraction layer) is now deprecated on freedesktop environment, and it is emerged into udev package. In HAL's offical website, It declared that HAL is in maintenance mode, all future development focus in udisks and upower. So I guess upower maybe provide some power management interface.

I use d-feet to search system bus channel, and found Suspend method in org.freedesktop.UPower bus name.


2 Two ways to Suspend/Hibernate the Laptop

  • Use dbus interface provided by upower

The new script to suspend PC:
#!/bin/bash

dbus-send --system --print-reply --dest=org.freedesktop.UPower \
     /org/freedesktop/UPower \
      org.freedesktop.UPower.Suspend

To Hibernate the PC:
#!/bin/bash

dbus-send --system --print-reply --dest=org.freedesktop.UPower \
     /org/freedesktop/UPower \
      org.freedesktop.UPower.Hibernate
  • Use pm-utils command

The pm-utils package provide the some power management utilities. But you need the root privilege to operate them, or you can grant the privilege via sudo.
pm-suspend
pm-hibernate

Comments

Popular posts from this blog

Bluedroid stack in android

How to setup a NAT server?

Network programming in elisp