mirror of
https://github.com/balena-io/etcher.git
synced 2025-08-06 09:57:45 +00:00
Screensaver for etcher-pro
Change-type: patch
This commit is contained in:
parent
791c047fa1
commit
7be07bfe8c
@ -45,6 +45,7 @@ const driveScanner = require('./modules/drive-scanner')
|
|||||||
const osDialog = require('./os/dialog')
|
const osDialog = require('./os/dialog')
|
||||||
const exceptionReporter = require('./modules/exception-reporter')
|
const exceptionReporter = require('./modules/exception-reporter')
|
||||||
const updateLock = require('./modules/update-lock')
|
const updateLock = require('./modules/update-lock')
|
||||||
|
const screensaver = require('./modules/screensaver')
|
||||||
|
|
||||||
/* eslint-disable lodash/prefer-lodash-method,lodash/prefer-get */
|
/* eslint-disable lodash/prefer-lodash-method,lodash/prefer-get */
|
||||||
|
|
||||||
@ -506,3 +507,5 @@ angular.element(document).ready(() => {
|
|||||||
angular.bootstrap(document, [ 'Etcher' ])
|
angular.bootstrap(document, [ 'Etcher' ])
|
||||||
}).catch(exceptionReporter.report)
|
}).catch(exceptionReporter.report)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
screensaver.init()
|
||||||
|
63
lib/gui/app/modules/screensaver.ts
Normal file
63
lib/gui/app/modules/screensaver.ts
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 resin.io
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { execFile } from 'child_process';
|
||||||
|
import { promisify } from 'util';
|
||||||
|
|
||||||
|
const execFileAsync = promisify(execFile);
|
||||||
|
const EVENT_TYPES = [
|
||||||
|
'focus',
|
||||||
|
'keydown',
|
||||||
|
'keyup',
|
||||||
|
'pointerdown',
|
||||||
|
'pointermove',
|
||||||
|
'pointerup',
|
||||||
|
] as const;
|
||||||
|
const SCREENSAVER_DELAY = 30 * 1000; // TODO: make this configurable
|
||||||
|
|
||||||
|
function exec(
|
||||||
|
command: string,
|
||||||
|
...args: string[]
|
||||||
|
): Promise<{ stdout: string; stderr: string }> {
|
||||||
|
return execFileAsync(command, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function screenOff(): Promise<void> {
|
||||||
|
await exec('xset', 'dpms', 'force', 'suspend');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function ledsOn(): Promise<void> {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
async function ledsOff(): Promise<void> {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
async function off() {
|
||||||
|
await Promise.all([ledsOff(), screenOff()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function init(): void {
|
||||||
|
let timeout = setTimeout(screenOff, SCREENSAVER_DELAY);
|
||||||
|
for (const eventType of EVENT_TYPES) {
|
||||||
|
addEventListener(eventType, async () => {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
timeout = setTimeout(off, SCREENSAVER_DELAY);
|
||||||
|
await ledsOn();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -120,4 +120,19 @@ module.exports = function (WarningModalService) {
|
|||||||
this.shouldShowUnsafeMode = () => {
|
this.shouldShowUnsafeMode = () => {
|
||||||
return !settings.get('disableUnsafeMode')
|
return !settings.get('disableUnsafeMode')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @summary Show the enableScreensaver setting
|
||||||
|
* @function
|
||||||
|
* @public
|
||||||
|
*
|
||||||
|
* @returns {Boolean}
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* SettingsController.shouldShowEnableScreensaver()
|
||||||
|
*/
|
||||||
|
this.shouldShowEnableScreensaver = () => {
|
||||||
|
return settings.get('showEnableScreensaver')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,4 +77,14 @@
|
|||||||
<span>Unsafe mode <span class="label label-danger">Dangerous</span></span>
|
<span>Unsafe mode <span class="label label-danger">Dangerous</span></span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="checkbox" ng-if="settings.shouldShowEnableScreensaver()">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox"
|
||||||
|
tabindex="11"
|
||||||
|
ng-model="settings.currentData.enableScreensaver"
|
||||||
|
ng-change="settings.toggle('enableScreensaver')">
|
||||||
|
<span>Enable screensaver</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
20
npm-shrinkwrap.json
generated
20
npm-shrinkwrap.json
generated
@ -1054,9 +1054,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "6.14.3",
|
"version": "10.14.9",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-6.14.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.9.tgz",
|
||||||
"integrity": "sha512-V2VrQBCKo4U0rni6tW4AASRDqIO5ZTLDN/Xzrm4mNBr9SGQYZ+7zZJn+hMs89Q8ZCIHzp4aWQPyCpK+rux1YGA=="
|
"integrity": "sha512-NelG/dSahlXYtSoVPErrp06tYFrvzj8XLWmKA+X8x0W//4MqbUyZu++giUG/v0bjAT6/Qxa8IjodrfdACyb0Fg=="
|
||||||
},
|
},
|
||||||
"@types/optimist": {
|
"@types/optimist": {
|
||||||
"version": "0.0.29",
|
"version": "0.0.29",
|
||||||
@ -5500,6 +5500,13 @@
|
|||||||
"unzip-stream": "^0.3.0",
|
"unzip-stream": "^0.3.0",
|
||||||
"xxhash": "github:balena-io-modules/node-xxhash#70ac31da1a41c6f8c53d931b5802c6c93f7b6b83",
|
"xxhash": "github:balena-io-modules/node-xxhash#70ac31da1a41c6f8c53d931b5802c6c93f7b6b83",
|
||||||
"yauzl": "^2.9.2"
|
"yauzl": "^2.9.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": {
|
||||||
|
"version": "6.14.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-6.14.6.tgz",
|
||||||
|
"integrity": "sha512-rFs9zCFtSHuseiNXxYxFlun8ibu+jtZPgRM+2ILCmeLiGeGLiIGxuOzD+cNyHegI1GD+da3R/cIbs9+xCLp13w=="
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"event-emitter": {
|
"event-emitter": {
|
||||||
@ -8670,6 +8677,13 @@
|
|||||||
"@types/usb": "^1.5.1",
|
"@types/usb": "^1.5.1",
|
||||||
"debug": "^3.1.0",
|
"debug": "^3.1.0",
|
||||||
"usb": "github:resin-io/node-usb#1.3.6"
|
"usb": "github:resin-io/node-usb#1.3.6"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": {
|
||||||
|
"version": "6.14.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-6.14.6.tgz",
|
||||||
|
"integrity": "sha512-rFs9zCFtSHuseiNXxYxFlun8ibu+jtZPgRM+2ILCmeLiGeGLiIGxuOzD+cNyHegI1GD+da3R/cIbs9+xCLp13w=="
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node-releases": {
|
"node-releases": {
|
||||||
|
@ -86,6 +86,7 @@
|
|||||||
"@babel/plugin-proposal-function-bind": "^7.2.0",
|
"@babel/plugin-proposal-function-bind": "^7.2.0",
|
||||||
"@babel/preset-env": "^7.2.0",
|
"@babel/preset-env": "^7.2.0",
|
||||||
"@babel/preset-react": "^7.0.0",
|
"@babel/preset-react": "^7.0.0",
|
||||||
|
"@types/node": "^10.14.9",
|
||||||
"@types/react-dom": "^16.8.4",
|
"@types/react-dom": "^16.8.4",
|
||||||
"acorn": "^6.0.5",
|
"acorn": "^6.0.5",
|
||||||
"angular-mocks": "1.7.6",
|
"angular-mocks": "1.7.6",
|
||||||
@ -117,9 +118,9 @@
|
|||||||
"simple-progress-webpack-plugin": "^1.1.2",
|
"simple-progress-webpack-plugin": "^1.1.2",
|
||||||
"spectron": "^5.0.0",
|
"spectron": "^5.0.0",
|
||||||
"style-loader": "^0.23.1",
|
"style-loader": "^0.23.1",
|
||||||
"webpack": "^4.31.0",
|
|
||||||
"ts-loader": "^6.0.2",
|
"ts-loader": "^6.0.2",
|
||||||
"typescript": "^3.5.1",
|
"typescript": "^3.5.1",
|
||||||
|
"webpack": "^4.31.0",
|
||||||
"webpack-cli": "^3.1.2",
|
"webpack-cli": "^3.1.2",
|
||||||
"webpack-node-externals": "^1.7.2"
|
"webpack-node-externals": "^1.7.2"
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"lib/**/*.ts",
|
"lib/**/*.ts",
|
||||||
|
"node_modules/electron/**/*.d.ts",
|
||||||
"typings/**/*.d.ts"
|
"typings/**/*.d.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user