<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[npm library] @bugsounet/screen]]></title><description><![CDATA[<h3><a class="plugin-mentions-user plugin-mentions-a" href="/user/bugsounet" aria-label="Profile: bugsounet">@<bdi>bugsounet</bdi></a>/screen</h3>
<p dir="auto">I created this library if you want to manage for screen in your module.<br />
This library is very simplified and ready for use in your <code>node_helper.js</code></p>
<p dir="auto"><em>This library is used in MMM-Assistant2Display</em></p>
<p dir="auto">single node routine for managing your screen</p>
<h4>Installation</h4>
<pre><code class="language-sh">npm install @bugsounet/screen
</code></pre>
<h4>Sample with screen contructor</h4>
<pre><code class="language-js">const Screen = require("@bugsounet/screen")

this.config = {
  delay: 10 * 1000,
  turnOffDisplay: true,
  ecoMode: true,
  displayCounter: true,
  detectorSleeping: true,
  governorSleeping: true,
  rpi4: false,
  linux: false
}

var debug = true

this.screen = new Screen(this.config, callback, debug, detectorControl, governorControl)
this.screen.start()
setTimeout(() =&gt; { this.screen.state() } , 5 * 1000)
setTimeout(() =&gt; { this.screen.stop() } , 15 * 1000)

function callback(noti, value) {
  if (noti == "SCREEN_TIMER") console.log ("Turn off in", value)
  else console.log("Screen Notification:", noti)
}

function detectorControl(noti) {
  console.log("detectorControl Notification:", noti)
}

function governorControl(noti) {
  console.log("governorControl Notification:", noti)
}
</code></pre>
<h4>constructor of screen</h4>
<p dir="auto">Screen(screenConfig, callback, debug, detectorControl, governorControl)</p>
<h5>screenConfig {}</h5>
<ul>
<li><code>delay</code> - Time before turns off the display. (in ms).</li>
<li><code>turnOffDisplay</code> - Should the display turn off after timeout?</li>
<li><code>ecoMode</code> - send a notification to hide all module after timeout?</li>
<li><code>displayCounter</code> - send a notification with count-down before sleeping</li>
<li><code>detectorSleeping</code> - send a notification to manage detector when screen is off</li>
<li><code>governorSleeping</code> - send a notification to manage governor when screen is off</li>
<li><code>rpi4</code> -  rpi4 support (use dpms)</li>
<li><code>linux</code> - linux support (use dpms)</li>
</ul>
<h5>callback (notification,value)</h5>
<ul>
<li><code>SCREEN_TIMER</code> - Display the count down before sleeping mode (require <code>displayCounter</code>)</li>
<li><code>SCREEN_SHOWING</code> - return notification for showing modules or other (require <code>ecoMode</code>)</li>
<li><code>SCREEN_HIDING</code> - return notification for hiding modules or other (require <code>ecoMode</code>)</li>
<li><code>SCREEN_STATE</code> - return object with actual screen state<br /><br />
object value:
<ul>
<li><code>running</code>: return <code>true</code> if <code>screen</code> main script with count down is running</li>
<li><code>locked</code>: return <code>true</code> if <code>screen</code> function is locked</li>
<li><code>power</code>: return <code>true</code> if your display is On</li>
</ul>
</li>
</ul>
<pre><code class="language-js">{
  running: true,
  locked: false,
  power: true
}
</code></pre>
<h5>detectorControl [optional]</h5>
<p dir="auto">require <a href="https://www.npmjs.com/package/@bugsounet/snowboy" target="_blank" rel="noopener noreferrer nofollow ugc">@bugsounet/snowboy</a> or compatible<br /><br />
require <code>detectorSleeping</code> and only work with <code>activate()</code> or <code>start()</code> function</p>
<ul>
<li><code>SNOWBOY_START</code> - return notification for start your detector</li>
<li><code>SNOWBOY_STOP</code> - return notification for stop your detector</li>
</ul>
<h5>governorControl [optional]</h5>
<p dir="auto">require <a href="https://www.npmjs.com/package/@bugsounet/governor" target="_blank" rel="noopener noreferrer nofollow ugc">@bugsounet/governor</a><br /><br />
require <code>governorSleeping</code> and only work with <code>activate()</code> or <code>start()</code> function</p>
<ul>
<li><code>GOVERNOR_WORKING</code> - return notification to change your governor to working configuration</li>
<li><code>GOVERNOR_SLEEPING</code> - return notification to change your governor to sleeping configuration</li>
</ul>
<h5>debug</h5>
<p dir="auto">if you want debuging information, just set to <code>true</code></p>
<h4>Functions</h4>
<ul>
<li><code>activate()</code>: activate main <code>screen</code> script with count down (use it with first use)<br /><br />
it force turn on display when escape the script (ctl + c)</li>
<li><code>start()</code>: start <code>screen</code> script with count down</li>
<li><code>stop()</code>: stop <code>screen</code> script</li>
<li><code>reset()</code>: reset count down</li>
<li><code>wakeup()</code>: wake up the screen</li>
<li><code>lock()</code>: lock the screen (start/stop/reset/wakeup will be ignored)</li>
<li><code>unlock()</code>: unlock the screen</li>
<li><code>wantedPowerDisplay(wanted)</code>: comparate actual screen state and apply it if not set.<br /><br />
<code>wanted</code> value is boolean:
<ul>
<li><code>true</code>: turn on screen</li>
<li><code>false</code>: turn off screen</li>
</ul>
</li>
<li><code>setPowerDisplay(set)</code>: like <code>wantedPowerDisplay()</code> but you force to apply it<br />
<code>set</code> value is boolean:
<ul>
<li><code>true</code>: force turn on screen</li>
<li><code>false</code>: force turn off screen</li>
</ul>
</li>
<li><code>state()</code>: return state of <code>screen</code> in object</li>
</ul>
<h5>Notes</h5>
<ul>
<li><code>turnOffDisplay</code> work only with <code>activate()</code> or <code>start()</code> function</li>
<li>you can use only <code>wantedPowerDisplay()</code> or <code>setPowerDisplay()</code> without main script !</li>
</ul>
]]></description><link>https://forum.magicmirror.builders/topic/12830/npm-library-bugsounet-screen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Jul 2026 02:04:14 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/12830.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 14 May 2020 09:50:00 GMT</pubDate><ttl>60</ttl></channel></rss>