I would like to suspend my xubuntu (14.04) system from a keyboard shortcut without entering my superuser password (sudo). I'm looking a command line which I can convert to a shortcut.

So far, I tried two solutions:

Xfce command:

xfce4-session-logout --suspend

Problem: The system doesn't lock the session. I don't need to enter my password for the wake-up and I want to do it.


dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend

Problem: After wake-up, the Internet connection is down and I have to reboot the system to get it back.

Is there a third solution which 1. ask the password during the wake-up process, and 2. doesn't mess up with Internet connection?

In fact, the graphical default shortcut (from the menu) works fine. I just don't know which command line is called.

6 Answers 6


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)

# 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)

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

# When we wake up, turn the lights back on
xbacklight -set $previous_dimness
  • 1
    +1 for the wonderful comments. I think I will use this script when I install Ubuntu.
    – Wildcard
    Commented Dec 12, 2015 at 3:21
  • Im sorry but where should I place this script? how should I connect it with a keyboard shortcut (for example ctrl+alt+s)? I am using Lubuntu Commented Aug 12, 2017 at 15:29
  • You can technically put the script anywhere. I have a bin/ directory under my home directory just for personal scripts like this that I want to use. In this case, the path to the script is: /home/<username>/bin/custom-suspend You'll want to make sure the script is executable. One way to do that is to run the following command: $ chmod +x /home/<username>/bin/custom-suspend To give it a shortcut under LXDE (which Lubuntu) uses, you should be able to search for something like 'keyboard' from the start menu, which should show you the keyboard config app.
    – Jon Carter
    Commented Aug 14, 2017 at 3:53

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

  • That works from command line (although the lock screen is unnecessary since that's automatic with suspend), but not as a keyboard application shortcut (at least with Ubuntu 12.04). By the way, the Xfce app for locking the screen is xflock4 (no args), which by default is bound to control-alt-delete. Commented Oct 22, 2015 at 18:21
  • xscreensaver-command seems to be gone in 15.10. Commented Jan 14, 2016 at 23:54
  • @JesseGlick - just install the xscreensaver package
    – Wilf
    Commented Jan 15, 2016 at 17:28

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.

  • That works from command line (although the lock screen is unnecessary since that's automatic with suspend), but not as a keyboard application shortcut (at least with Ubuntu 12.04). Commented Oct 22, 2015 at 18:21
  • well, it is supposed to work in xubuntu, not ubuntu. I am not sure why do you even have the xfce4-session-logout command.
    – Ufos
    Commented Oct 23, 2015 at 14:41
  • We are talking Xfce, which can be added to any ubuntu distribution. Xubuntu is simply a convenience distro that happens to have added Xfce packages and configured them as a desktop. You can start with ubuntu and add/configure it yourself. The xubuntu/ubuntu distinction is a red herring here. Commented Oct 23, 2015 at 18:21
  • Working fine for me, with screen lock, in Xubuntu 15.10. Commented Jan 15, 2016 at 0:25

This command works for me: I just make a launcher for desktop and set the Shutdown Icon for that. put this command in command filed:

dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend

fist time ask me to make Executable and after that working very well.

I'm using wicd for Internet connection and It's working well too after waking up!

  • Xubuntu 15.10: Error org.freedesktop.DBus.Error.UnknownMethod: Method "Suspend" with signature "" on interface "org.freedesktop.UPower" doesn't exist Commented Jan 14, 2016 at 23:53

If you're on a laptop and just want a key to press. You can use the power button. The behavior can be set from the Power settings:

  1. Open Settings Manager (or by command : xfce4-settings-manager )
  2. Open Power Manager settings
  3. In General : set When power button is pressed to Ask
  4. Close Power Manager settings

If you have ACPI scripts installed, deactivate or update the power-button script from

/etc/acpi/events/, and change the action field to /bin/true:

Ref: https://wiki.xfce.org/tips#solution_2


With the current version of Xfce, which at this time is 4.18, when the system is suspended (xfce4-session-logout --suspend), it is also locked automatically. There is no need to write a shell script to lock the session (xflock4) alongside suspending it (Jon Carter answer).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .