如何使用键盘快捷键挂起?

ppr

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

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

Xfce命令:

xfce4-session-logout --suspend

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

Dbus

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

问题:唤醒后,Internet连接已断开,我必须重新引导系统才能将其恢复。

是否存在第三个解决方案,即1.在唤醒过程中询问密码,并且2.不打乱Internet连接?

实际上,图形默认快捷方式(从菜单中)可以正常工作。我只是不知道调用哪个命令行。

乔恩·卡特

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

#!/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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章