X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;ds=sidebyside;f=stage2%2Fmisc%2Facpi%2Fsuspend2ram.sh;h=d3429908828f0a9923b66eaf8120674a047416ef;hb=8be3c0cbe1565c3773a7fdf3783dc3f1cf335b23;hp=528337517b7b18ca7bc27fe7a0a8c00a02697e1a;hpb=8a12114ecc9a0f7d97ab543785a1a758ea4d0973;p=hvlinux.git diff --git a/stage2/misc/acpi/suspend2ram.sh b/stage2/misc/acpi/suspend2ram.sh index 5283375..d342990 100755 --- a/stage2/misc/acpi/suspend2ram.sh +++ b/stage2/misc/acpi/suspend2ram.sh @@ -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@:@/@'` @@ -37,7 +48,11 @@ sync cat /proc/bus/pci/$ID > $TMP_FILE # Stopping network. -/etc/rc.d/init.d/named stop + +if [ -f /etc/rc.d/init.d/named ]; then + /etc/rc.d/init.d/named stop +fi + /etc/rc.d/init.d/network stop echo "Entering suspend mode" @@ -52,7 +67,10 @@ echo "Resuming" cat $TMP_FILE > /proc/bus/pci/$ID /etc/rc.d/init.d/network start -/etc/rc.d/init.d/named start + +if [ -f /etc/rc.d/init.d/named ]; then + /etc/rc.d/init.d/named start +fi # remove temporary file rm -f $TMP_FILE