You'll need to touch a file in /var/run, call it s3. Next, you'll need to include in your script that whenever the lid button or Fn+f3 is pressed, that file is touched and then go to suspend. When you wake it up, it should check for the file and clear it, then wake up the desktop.
Here's an example of my suspend script:
tmpfile=`mktemp` || exit 1
# Create a state file here and check it in /etc/acpi/powerbtn.sh so acpid
# knows that the power button press used to wake the machine shouldn't
# hibernate / shutdown / whatever
# Change to text mode to attempt to avoid hangs on resume with new
# radeon DRM driver
# These always seem to cause problems in whatever sleep mode
#modprobe -r ehci_hcd uhci_hcd ipw2200
modprobe -r ipw2200
# Save video state, go to S3, restore video state
videomode=`vbetool vbemode get`
vbetool vbestate save > $tmpfile
echo -n "mem" > /sys/power/state
vbetool vbestate restore < $tmpfile
vbetool vbemode set $videomode
# Change back from text mode
# Can't load them in parallel with & or nasty things happen
# Give ACPI time to get the machine back up, process thermal events, etc.
# After coming back from S3, the battery/AC power state is often messed up.
# Try to fix it here.
### Fixed by hacking DSDT?
# rmmod battery ac
# modprobe battery
# modprobe ac
rm -f $tmpfile
# starting anacron, otherwise cron jobs can be never restarted
And an example of my powerbutton script:
# Initiates a shutdown when the power putton has been
if [ -f /var/run/S3 ]; then
rm -f /var/run/S3