Chapter 9. Introducing the tray module

 

This chapter covers

  • Building a simple application that lives in the menu bar on macOS or the system tray in Windows.
  • Using Electron’s tray module to create applications that live in the operating system’s menu bar or system tray.
  • Reading from and writing to the system clipboard.
  • Registering global shortcuts that listen for specific keystrokes even when the application is not in use.
  • Triggering native notifications in macOS and Windows 10.

For most of the first half of the book, we worked on Fire Sale. Although its initial feature set in chapter 3 could have conceivably been matched by a traditional, browser-based web application, we spent the subsequent chapters adding functionality outside the scope of what most browsers allow. In this chapter, we begin well outside the realm of where we expect to find web technologies: the macOS menu bar and Windows system tray. In the beginning, we won’t have a renderer process or the DOM. By the end of this chapter, we explore how to create hidden renderer processes to access features not available to the main process. In the next chapter, we create a BrowserWindow to serve as the UI for our tray application.

9.1. Getting started with Clipmaster

9.2. Creating an application with the tray module

9.3. Reading from and writing to the clipboard

9.4. Registering global shortcuts

9.5. Displaying notifications

9.6. Switching menu bar icons when pressed in macOS

9.7. Completed code

Summary