March 23, 2018

Power Saving for the Workstation, Part 2

Automatically Suspending to RAM

  • July 31, 2007
  • By A. Lizard

In part 1, you were shown how to set up hibernate and modify the configuration scripts to make it possible to suspend your desktop to RAM. In part 2, you'll step through how to implement your changes.

In the KDE Control Center, drill down through Peripherals, Display, to the Power Saving tab. Check the Enable Power Saving checkbox and set time for "Switch Off Monitor." In a non-KDE environment, find "Display Power Management." That's what automatically turns off DPMS when the system is idling.

When your monitor is shut off via DPMS by whatever method, your computer will go into suspend if you install this script:

# put this in /usr/local/bin/
# put sh /usr/local/bin/
# default display on current host
# moved xset +dpms to icon
# try to make sure that monitor sessions don't multiply indefinitely
# note: the echo statements are for debugging when running in a terminal.
# the touch statements are also for debug. 
until [ "$STATUS" == "DPMS is Disabled" ]; do

STATUS=`xset -display $DISPLAY -q | grep -o 'DPMS is Disabled'`
if [ "$STATUS" == "DPMS is Disabled" ]
echo "end suspend monitor loop - DPMS Disabled"
touch /home/username/suspend/dpms-disabled

STATUS=`xset -display $DISPLAY -q | grep -o 'DPMS is Enabled'`
if [ "$STATUS" == "DPMS is Enabled" ]
then echo "SUSPEND script - DPMS working - continue monitoring" 
touch /home/username/suspend/dpms-enabled

STATUS=`xset -display $DISPLAY -q | grep -o 'Monitor is On'`
if [ "$STATUS" == "Monitor is On" ]
then echo "Monitor is On - script"
touch /home/username/suspend/monitor-is-on

STATUS=`xset -display $DISPLAY -q | grep -o 'Monitor is Off'`
if [ "$STATUS" == "Monitor is Off" ]
then touch /home/username/suspend/monitor-is-off
echo "Monitor is Off - script"
hibernate-ram --force
echo "hibernate-ram terminated"

STATUS=`xset -display $DISPLAY -q | grep -o 'Monitor is in Suspend'`
if [ "$STATUS" == "Monitor is in Suspend" ]
then echo "Monitor is in Suspend - script"
touch /home/username/suspend/monitor-is-suspend
hibernate-ram --force

STATUS=`xset -display $DISPLAY -q | grep -o 'Monitor is in Standby'`
if [ "$STATUS" == "Monitor is in Standby" ]
then echo "Monitor is in Standby-script"
touch /home/username/suspend/monitor-is-standby
hibernate-ram --force
sleep 30

The touch statements are there for diagnostic purposes, they aren't necessary to the normal operation of the script, but the touch statements will tell you where the script crashed by simply checking to see what is in /home/username/suspend. Clear the directory before running the script if you're debugging.

Most Popular LinuxPlanet Stories

Sitemap | Contact Us