window-button-layout
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

window-button-layout

Retrieve OS window buttons layout (close, maximize, minimize...) depending on platform and user preferences. Useful to create a custom window title in Electron that matches the rest of the OS for a more coherent UX.

Currently supported:

  • Windows
  • MacOS
  • KDE
  • Gnome
  • Pantheon (elementaryOS)

Installation

yarn add window-button-layout

Usage

Must be used in a Node context! In an electron app, you can use IPC to send the result to your frontend code.

The getWindowButtonLayout function will return a WindowButtonLayout object:

const { getWindowButtonLayout } = require('window-button-layout')

console.log(getWindowButtonLayout())
/*
{
  start: ['menu'],
  end: ['minimize', 'maximize', 'close']
}
*/

Depending on the OS and user preferences, you will get different arrays for start (left-side) and end (right-side). All buttons are not necessarily used; for example, on Pantheon (elementaryOS) there are no menu and minimize window buttons.

Interfaces:

enum WindowButton {
  CLOSE = 'close',
  MAXIMIZE = 'maximize',
  MINIMIZE = 'minimize',
  SPACER = 'spacer',
  MENU = 'menu',
}

interface WindowButtonLayout {
  start: WindowButton[]
  end: WindowButton[]
}

Unkown buttons (that are not in the WindowButton enum) will be ignored.

/window-button-layout/

    Package Sidebar

    Install

    npm i window-button-layout

    Weekly Downloads

    2

    Version

    0.1.1

    License

    MIT

    Unpacked Size

    9.43 kB

    Total Files

    7

    Last publish

    Collaborators

    • akryum