How to suspend with a keyboard shortcut?

I wrote a script. It seems to do what you ask for:

#!/usr/bin/env zsh
# Custom suspend
#
# (That 'zsh' up there can be switched to 'bash', or 
# pretty much any shell - this doesn't do anything too fancy.)
#
# Dependencies are mostly xfce stuff:
#
#   xbacklight
#   xflock4
#   xfce4-session-logout

# Set how dim we want the screen to go (percentage, out of 100)
dim=5

# Pack up your toys
previous_dimness=$(xbacklight -get)

# Turn down the lights
xbacklight -set $dim

# Lock the door (this requires a password to get back in)
xflock4

# And go to sleep
xfce4-session-logout --suspend

# When we wake up, turn the lights back on
xbacklight -set $previous_dimness

You can very simply send the command for it to lock screen first, and then have it suspend:

xscreensaver-command -lock ; xfce4-session-logout --suspend

For usage of xscreensaver-command, run xscreensaver-command --help


Oddly enough xfce4-session-logout --suspend works just fine, and my system is xubuntu 14.04. It also does lock the session, although I have switched on the option "lock screen before sleep", go to Settings->Session and Startup-> Advanced, and check if it switched on there.