OSX : check if screen is sleep or awake from command line
<p>Is there any way by which i can check whether the screen is asleep or awake from the command line or by applescript ?</p>

<p>Related to this - <a href="https://stackoverflow.com/questions/32319778/check-if-display-is-sleeping-in-applescript">Check if display is sleeping in Applescript</a></p>

<p>A little background on why do i need to detect whether the screen state is sleep or awake :</p>

<p>I am creating an app using node-webkit and in the app we track the user's usage ( screenshot, process and website usage ) to calculate the total productive hours worked.</p>

<p>I need to detect the screen sleep / awake event so that i can start and stop the app acordingly.</p>

<p>In linux and windows I am able to detect this in Javascript ( Node webkit apps are built in Javascript ) as shown in the below mentioned links but that doesn't seem to be working in osx :</p>

<p><a href="https://blog.alexmaccaw.com/javascript-wake-event" rel="nofollow noreferrer">https://blog.alexmaccaw.com/javascript-wake-event</a></p>

<p><a href="https://stackoverflow.com/questions/4079115/can-any-desktop-browsers-detect-when-the-computer-resumes-from-sleep">Can any desktop browsers detect when the computer resumes from sleep?</a></p>