Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ There is an issue template for you to follow. Please provide as much information
Thank you in advance for your help.

### When you open a pull request
There is a pull request template for your to follow. Please fill in the template before submitting your code. Your pull request will be reviewed faster if we know exactly what it does.
There is a pull request template for you to follow. Please fill in the template before submitting your code. Your pull request will be reviewed faster if we know exactly what it does.

Make sure that you have:
- Checked [`code_style.md`](docs/code_style.md) for information on code style
Expand Down
6 changes: 6 additions & 0 deletions lib/main-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ app.on('ready', function() {
mainWindow.setMenu(menu)
}

// Create tray icon for Linux (fixes issue #377)
if (process.platform === 'linux') {
const mainTray = require('./main-tray')
mainTray.createTray(mainWindow)
}

// Check update every day
setInterval(function() {
if (isPackaged) checkUpdate()
Expand Down
102 changes: 102 additions & 0 deletions lib/main-tray.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
const { Tray, Menu, app, nativeImage } = require('electron')
const path = require('path')

let tray = null

/**
* Create tray icon for Linux
* This functionality was missing in the original codebase
* Issue: https://github.com/BoostIO/BoostNote-Legacy/issues/377
*/
function createTray(mainWindow) {
// Only create tray on Linux
if (process.platform !== 'linux') {
return null
}

// Get the appropriate tray icon
const iconPath = path.join(__dirname, '../resources/tray-icon.png')

// Create native image for tray icon
let icon
try {
icon = nativeImage.createFromPath(iconPath)

// Try @2x version for HiDPI displays
if (icon.isEmpty()) {
const iconPath2x = path.join(__dirname, '../resources/tray-icon@2x.png')
icon = nativeImage.createFromPath(iconPath2x)
}
} catch (e) {
console.error('Failed to load tray icon:', e)
return null
}

if (icon.isEmpty()) {
console.warn('Tray icon is empty, skipping tray creation')
return null
}

// Create tray
tray = new Tray(icon)

// Set tooltip
tray.setToolTip('Boostnote')

// Context menu
const contextMenu = Menu.buildFromTemplate([
{
label: 'Show Boostnote',
click: () => {
if (mainWindow) {
mainWindow.show()
mainWindow.focus()
}
}
},
{
label: 'Hide Boostnote',
click: () => {
if (mainWindow) {
mainWindow.hide()
}
}
},
{ type: 'separator' },
{
label: 'Quit',
click: () => {
app.quit()
}
}
])

tray.setContextMenu(contextMenu)

// Handle click - show/hide window
tray.on('click', () => {
if (mainWindow) {
if (mainWindow.isVisible()) {
mainWindow.hide()
} else {
mainWindow.show()
mainWindow.focus()
}
}
})

// Handle double-click - show window
tray.on('double-click', () => {
if (mainWindow) {
mainWindow.show()
mainWindow.focus()
}
})

return tray
}

module.exports = {
createTray,
getTray: () => tray
}