Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/viktor-shmigol/electron-windows-badge
Electron Windows Badge plugin to access and modify the badge number of the app icon in windows.
https://github.com/viktor-shmigol/electron-windows-badge
badge electron js windows
Last synced: 13 days ago
JSON representation
Electron Windows Badge plugin to access and modify the badge number of the app icon in windows.
- Host: GitHub
- URL: https://github.com/viktor-shmigol/electron-windows-badge
- Owner: viktor-shmigol
- License: mit
- Created: 2018-07-01T18:31:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-03-01T20:08:21.000Z (11 months ago)
- Last Synced: 2025-01-16T02:13:39.157Z (21 days ago)
- Topics: badge, electron, js, windows
- Language: JavaScript
- Homepage:
- Size: 59.6 KB
- Stars: 81
- Watchers: 4
- Forks: 22
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Electron Windows Badge
Electron Windows Badge plugin to access and modify the badge number of the app icon in windows.
## Installation
$ npm i electron-windows-badge --save## Usage
1) Require electron-windows-badge in your main process:
const Badge = require('electron-windows-badge');2) Initialize new object of badge while creating window:
function createWindow () {
win = new BrowserWindow({width: 800, height: 600});
const badgeOptions = {}
new Badge(win, badgeOptions);
}3) To update the badge you just need to call this(you must do it in render process):
ipcRenderer.sendSync('update-badge', 1);4) To remove badge just call this(you must do it in render process):
ipcRenderer.sendSync('update-badge', null);
#### Usage on Main Process
1) Require electron-windows-badge in your main process:
const Badge = require('electron-windows-badge');2) Initialize new object of badge while creating window:
function createWindow () {
win = new BrowserWindow({width: 800, height: 600});
const badgeOptions = {}
const winBadge = new Badge(win, badgeOptions);
setupWinBadge(win, winBadge);
}
function setupWinBadge(win, winBadge) {
win.on('page-title-updated', (event, title) => {
// consider getCounterValue as a method that gets
// the number of notifications from the title, eg: (2) My App.
const counter = getCounterValue(title);
winBadge.update(counter);
});
}## API
**Badge options**
| Option Name | Default Value | Description |
| --------------------- | ------------------| ----------- |
| `fontColor ` | 'white' | Font color |
| `font ` | '24px arial' | Font style |
| `color ` | 'red' | The color of badge |
| `fit` | true | Be sure that your number will be fit into badge|
| `decimals ` | 0 | Numbers after dot (For float numbers) |
| `radius` | 8 | The radius of badge |## License
[MIT](LICENSE)