【问题标题】:OSX : check if screen is sleep or awake from command lineOSX:从命令行检查屏幕是睡眠还是唤醒
【发布时间】:2016-09-13 11:08:26
【问题描述】:

有什么方法可以通过命令行或applescript检查屏幕是休眠还是唤醒?

与此有关 - Check if display is sleeping in Applescript

关于为什么我需要检测屏幕状态是睡眠还是唤醒的一点背景:

我正在使用 node-webkit 创建一个应用程序,在该应用程序中,我们跟踪用户的使用情况(屏幕截图、流程和网站使用情况)以计算总工作时间。

我需要检测屏幕睡眠/唤醒事件,以便我可以相应地启动和停止应用程序。

在 linux 和 windows 中,我可以在 Javascript 中检测到这一点(Node webkit 应用程序是用 Javascript 构建的),如下面提到的链接所示,但这似乎在 osx 中不起作用:

https://blog.alexmaccaw.com/javascript-wake-event

Can any desktop browsers detect when the computer resumes from sleep?

【问题讨论】:

    标签: macos applescript


    【解决方案1】:

    “dsyp”是您要查找的值:

    set x to do shell script "ioreg -c AppleBacklightDisplay | grep brightness"
    
    # lcd on:  dsyp\"={\"min\"=0,\"max\"=2,\"value\"=2}
    # lcd off: dsyp\"={\"min\"=0,\"max\"=2,\"value\"=0}
    

    【讨论】:

      猜你喜欢
      • 2015-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-08
      • 2018-12-04
      • 1970-01-01
      • 2012-05-22
      相关资源
      最近更新 更多