Update X.org packages (fixes bug with intel driver)
[hvlinux.git] / stage2 / misc / acpi / suspend2ram.sh
index 5283375..6fdbd96 100755 (executable)
@@ -22,6 +22,17 @@ esac
 
 logger "Going to sleep"
 
+XSCREENSAVER_ACTIVE="$(pidof /usr/bin/xscreensaver)"
+
+# Check if xscreensaver is running. if not, just skip on.
+if [ "x${XSCREENSAVER_ACTIVE}" != "x" ]; then
+    # Run the lock command as the user who owns xscreensaver process,
+    # and not as root, which won't work.
+    su "$(ps aux | grep xscreensaver | grep -v grep | grep ${XSCREENSAVER_ACTIVE} | awk '{print $1}' )" \
+        -c "/usr/bin/xscreensaver-command -lock" &
+    sleep 1
+fi
+
 # discover video card's ID
 ID=`lspci | grep VGA | awk '{ print $1 }' | sed -e 's@0000:@@' -e 's@:@/@'`
 
@@ -36,13 +47,8 @@ sync
 # temporary file
 cat /proc/bus/pci/$ID > $TMP_FILE
 
-# Stopping network.
-/etc/rc.d/init.d/named stop
-/etc/rc.d/init.d/network stop
-
 echo "Entering suspend mode"
 
-# suspend
 echo -n mem > /sys/power/state
 
 echo "Resuming"
@@ -51,8 +57,5 @@ echo "Resuming"
 # on resume
 cat $TMP_FILE > /proc/bus/pci/$ID
 
-/etc/rc.d/init.d/network start
-/etc/rc.d/init.d/named start
-
 # remove temporary file
 rm -f $TMP_FILE