Script: Gotosleep

Sometimes we need to suspend the machine when certain job is completed. Following is my gotosleep script to suspend my Ubuntu.

# ---- filename: gotosleep ----
#!/bin/bash
# This script will suspend this machine to sleep mode.
gnome-screensaver-command --lock
sleep 1 
dbus-send --system --print-reply --dest="org.freedesktop.Hal" /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:0
# ------------------------------

#

Ubuntu 11.04 requires HAL to provide abstract view on hardware. Thus,

sudo apt-get install hal
Advertisements

Author: zkchong

I have been teaching in university for 7 years and currently a data science engineer at Axiata Digital Advertising, Malaysia.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s