Detecting inactivity from AppleScript

applescript, macos, osx-mavericks

Solution

Check out the manual page for "pmset". There is the whole thing described. It can list assertions.

pmset -g

You can check that way if the power management has any such assertions...

For example, when VLC is playing a movie, "pmset -g" shows:

 displaysleep 10 (display sleep prevented by VLC)

Problem

I have an AppleScript that warns me when the screen is about to lock and go to screensaver because of the mouse and keyboard being idle. However, it warns me when I am watching a video. Here is a snippet of the current way I'm detecting idle time: ``` set idleTime to (do shell script "ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print int($NF/1000000000); exit}'") as number ``` Is there a better way in AppleScript to detect inactivity (especially around watching videos) than doing the above? I'm on OSX-Mavericks

Original source