如何使用键盘快捷键暂停?

ppr*_*ppr 12 xfce suspend xubuntu

我想从键盘快捷键挂起我的xubuntu (14.04) 系统,而无需输入我的超级用户密码 ( sudo )。我正在寻找一个可以转换为快捷方式的命令行。

到目前为止,我尝试了两种解决方案:

Xfce 命令:

xfce4-session-logout --suspend
Run Code Online (Sandbox Code Playgroud)

问题:系统没有锁定会话。我不需要输入唤醒密码,我想这样做。

总线

dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend
Run Code Online (Sandbox Code Playgroud)

问题:唤醒后,互联网连接中断,我必须重新启动系统才能恢复。

是否有第三种解决方案,1. 在唤醒过程中询问密码,2. 不搞乱互联网连接?

事实上,图形默认快捷方式(来自菜单)工作正常。我只是不知道调用了哪个命令行。

小智 8

我写了一个脚本。它似乎可以满足您的要求:

#!/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
Run Code Online (Sandbox Code Playgroud)