抓住盖子关闭并打开事件

我试着写一个像这个建议的脚本:

关闭盖子时如何配置屏幕锁定?

我创建了一个目录和一个新的脚本文件:

mkdir /etc/acpi/local gksudo gedit /etc/acpi/local/lid.sh.post 

文件/etc/acpi/local/lid.sh.post包含以下代码:

 #!/bin/sh ######################################################################### ## Script written by Ruben Barkow ## ## https://gist.githubusercontent.com/rubo77/1a3320fda5a47fdebde7/raw/87cde3f0554467a132aba3cda7ad3c5e7187571f/lid.sh.post ## Description: This script reacts if laptop lid is opened or ## ## closed in Ubuntu 11.10 (Oneiric Ocelot). ## ## ## ## This script can be freely redistributed, modified and used. ## ## Any redistribution must include the information of authors. ## ## ## ## THIS SCRIPT HAS NO WARRANTY! ## ######################################################################### grep -q close /proc/acpi/button/lid/*/state if [ $? = 0 ]; then echo close>>/tmp/screen.lid fi grep -q open /proc/acpi/button/lid/*/state if [ $? = 0 ]; then echo open>>/tmp/screen.lid fi 

我试图让它在Ubuntu 14.04中运行,但为什么这没有效果。

在Ubuntu 14.04中是否有一种新的方式来捕捉盖子关闭和打开事件?

我在这里得到了一个提示: https : //askubuntu.com/a/518825/34298

  • 打开或关闭盖子时要调用的脚本必须存储
    /etc/acpi/lid.sh

  • 然后必须创建正确的文件/etc/acpi/events/lm_lid ,内容如下:

     event=button/lid.* action=/etc/acpi/lid.sh 
  • 重新启动系统以使其生效。 或者也许足以重新启动您的ACPI

     sudo /etc/init.d/acpid restart