#!/bin/bash

# suspend-to-ram : Sends the machine to S3, 
# performing some tasks before and after wakeup.

echo -e "\e[1;31mInitiating suspend-to-ram \e[0m"

# stop the wireless, if running (need to restart it manually)
ifconfig atml0 down

# Empty logfile
echo > /tmp/suspend.log

/sbin/hotplug stop >> /tmp/suspend.log 2>&1

# Flush disk buffers, so we won't lose to much data in case it fails
sync

# Go, sleep!
chvt 10
echo 3 > /proc/acpi/sleep
vbetool post
chvt 3
# vbetool vbestate restore <$VBESTATE

echo -e "\e[1;32m... back \e[0m"

# http://bugme.osdl.org/show_bug.cgi?id=3609
# setpci -s 00:1f.0 f2.b=1

/sbin/hotplug start >> /tmp/suspend.log 2>&1

