Book Image

Building Cross-Platform Desktop Applications with Electron

By : Muhammed Jasim
Book Image

Building Cross-Platform Desktop Applications with Electron

By: Muhammed Jasim

Overview of this book

<p>Though web applications are becoming increasingly popular, desktop apps are still important. The Electron framework lets you write cross-platform desktop applications using JavaScript, HTML, and CSS, and this book will teach you how to create your first desktop application with Electron. It will guide you on how to build desktop applications that run on Windows, Mac, and Linux platforms.</p> <p>You will begin your journey with an overview of Electron, and then move on to explore the various stages of creating a simple social media application. Along the way, you will learn how to use advanced Electron APIs, debug an Electron application, and make performance improvements using the Chrome developer tools. You’ll also find out how to package and distribute an application, and more.</p> <p>By the end of the book, you will be able to build a complete desktop application using Electron and web technologies. You will have a solid understanding of the common challenges that desktop app developers face, and you’ll know how to solve them.</p>
Table of Contents (19 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Managing display and power sleep mode


In some scenarios, we may need to control the machine or block the machine from entering into sleep mode. For example, if you are developing a media player application, the system should not go to sleep mode when playing a video, or your app should never turn off the power when playing the audio. Electron's powerSaveBlocker module gives you the access to the power and display mode. You can use this module to prevent the system from entering the low power mode. As we discussed, a classic example of this scenario is a video player. When the user clicks on the play button, you can ask this module to prevent low power mode, and you can stop monitoring the power state change when the user stops the playback. Here is an example for the powerSaveBlocker module:

<html>
<head>
</head>
<body>
<script language="javascript">
const { powerSaveBlocker } = require('electron').remote;
document.addEventListener("DOMContentLoaded", init, false...