Chapter 10. Building applications with the menubar library

 

This chapter covers

  • Creating an application with the menubar library
  • Sending HTTP requests with the request library
  • Creating clickable notifications
  • Adding secondary menus to tray instances

In the previous chapter, we created an application that lived in the menu bar on macOS or the system tray on Windows. Out of the box, Electron’s tray module allows you to set a menu to display when the user clicks the tray icon. This is the same type of menu used in the application and context menus that we built in Fire Sale. This menu also has the same limitations: it is limited to text, is hard to modify, and provides limited functionality.

Being able to build applications that live in the system tray or menu bar allows us to build entire classes of applications that we couldn’t build in the browser. It’s unfortunate that we have these restrictions, but—luckily—we can work around them. In this chapter, we explore a clever way to get around the limitations of the tray module using a third-party library conveniently called menubar.

menubar is an abstraction built on a set of core Electron modules that we’ve used previously in the book. A high-level explanation is that it creates an empty tray module. When the user clicks the icon, menubar shows a frameless, correctly positioned BrowserWindow instance beneath the icon, which creates the illusion that it’s attached to the icon. menubar also provides a cute cat icon by default.

10.1. Starting an application with menubar

10.2. Adding clippings to the UI

10.3. Working with clippings in the application

10.4. Publishing clippings

10.5. Displaying notifications and registering global shortcuts

10.6. Adding a secondary menu

Summary