Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
zh-cn:tips [2012/04/28 16:39] – [Handle acpi event for power button, show Xfce logout options] haobug | zh-cn:tips [2015/03/10 04:29] – [解决方案 2] yjwork | ||
---|---|---|---|
Line 138: | Line 138: | ||
如果你想在你按下电源按钮时显示注销菜单,并且你的机器支持 ACPI,那就按下面的步骤做吧: | 如果你想在你按下电源按钮时显示注销菜单,并且你的机器支持 ACPI,那就按下面的步骤做吧: | ||
- | ==== Solution | + | |
+ | ==== 解决方案 | ||
* ''/ | * ''/ | ||
- | < | + | < |
# / | # / | ||
- | # This is called when the user presses the power button and calls | + | # 当用户按下电源按钮时这文件会被调用并且调用 |
- | # / | + | # / |
- | + | ||
- | # Optionally you can specify the placeholder %e. It will pass | + | |
- | # through the whole kernel event message to the program you' | + | |
- | # specified. | + | |
- | # We need to react on " | + | # 你也可以用 %e 这个占位符来把整个内核事件消息传给你指定的程序。 |
- | # of kernel changes. | + | |
+ | # 我们需要对 | ||
+ | # 因为内核做了改动。 | ||
event=button[ /]power | event=button[ /]power | ||
Line 157: | Line 156: | ||
* ''/ | * ''/ | ||
- | < | + | < |
# | # | ||
# xfce4-shutdown-as-user.sh | # xfce4-shutdown-as-user.sh | ||
# | # | ||
- | # Check how many users are currently logged into X. | + | # 检查当前有多少用户登录了 |
- | # If only one user is logged in, run a script which sets | + | # 就执行脚本设置环境来调用 |
- | # up the environment to call xfce4-session-logout. | + | |
LOGGED_IN_USER=`ls -trl / | LOGGED_IN_USER=`ls -trl / | ||
Line 174: | Line 172: | ||
* ''/ | * ''/ | ||
- | < | + | < |
#!/bin/sh | #!/bin/sh | ||
# xfce4-user-session-shutdown.sh | # xfce4-user-session-shutdown.sh | ||
# | # | ||
- | # Set up the environment so that DISPLAY | + | # 设置环境变量,使 |
- | # SESSION_MANAGER are valid, and xfce4-session-logout | + | # 并且可以执行 |
HOST=`hostname` | HOST=`hostname` | ||
SESSION_ID=`ls -t / | SESSION_ID=`ls -t / | ||
- | # Note that distros use different syntax for the SESSION_MANAGER | + | # 注意,发行版们的 |
- | # If this does not work, then try something like SESSION_MANAGER=" | + | # 如果这个不能用,请试着修改为类似于 |
- | # instead. You can always find the correct format for your distribution by looking at the | + | # SESSION_MANAGER=" |
- | # value of SESSION_MANAGER in a X session. | + | # 通过在 X 会话中查看 SESSION_MANAGER 的值,你总可以找到你的发行版的正确的格式 |
DISPLAY=:0 SESSION_MANAGER=" | DISPLAY=:0 SESSION_MANAGER=" | ||
</ | </ | ||
- | | + | |
- | < | + | < |
chmod +x / | chmod +x / | ||
</ | </ | ||
- | ==== Solution | + | ==== 解决方案 |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
< | < | ||
event=button/ | event=button/ |