added a tray icon (fixes #226)
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
BIN
app/assets/tray-darwinHighlightTemplate.png
Normal file
After Width: | Height: | Size: 415 B |
BIN
app/assets/tray-darwinHighlightTemplate@2x.png
Normal file
After Width: | Height: | Size: 955 B |
BIN
app/assets/tray-darwinTemplate.png
Normal file
After Width: | Height: | Size: 365 B |
BIN
app/assets/tray-darwinTemplate@2x.png
Normal file
After Width: | Height: | Size: 894 B |
BIN
app/assets/tray.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
39
app/main.js
@ -32,6 +32,16 @@ if (!process.env.TERMINUS_PLUGINS) {
|
|||||||
setupWindowManagement = () => {
|
setupWindowManagement = () => {
|
||||||
app.window.on('show', () => {
|
app.window.on('show', () => {
|
||||||
app.window.webContents.send('host:window-shown')
|
app.window.webContents.send('host:window-shown')
|
||||||
|
if (app.tray) {
|
||||||
|
app.tray.destroy()
|
||||||
|
app.tray = null
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
app.window.on('hide', (e) => {
|
||||||
|
if (!app.tray) {
|
||||||
|
setupTray()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.window.on('close', (e) => {
|
app.window.on('close', (e) => {
|
||||||
@ -84,6 +94,35 @@ setupWindowManagement = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
setupTray = () => {
|
||||||
|
if (process.platform == 'darwin') {
|
||||||
|
app.tray = new electron.Tray(`${app.getAppPath()}/assets/tray-darwinTemplate.png`)
|
||||||
|
app.tray.setPressedImage(`${app.getAppPath()}/assets/tray-darwinHighlightTemplate.png`)
|
||||||
|
} else {
|
||||||
|
app.tray = new electron.Tray(`${app.getAppPath()}/assets/tray.png`)
|
||||||
|
}
|
||||||
|
|
||||||
|
app.tray.on('click', () => {
|
||||||
|
app.window.show()
|
||||||
|
app.window.focus()
|
||||||
|
})
|
||||||
|
|
||||||
|
const contextMenu = electron.Menu.buildFromTemplate([{
|
||||||
|
label: 'Show',
|
||||||
|
click () {
|
||||||
|
app.window.show()
|
||||||
|
app.window.focus()
|
||||||
|
}
|
||||||
|
}])
|
||||||
|
|
||||||
|
if (process.platform != 'darwin') {
|
||||||
|
app.tray.setContextMenu(contextMenu)
|
||||||
|
}
|
||||||
|
|
||||||
|
app.tray.setToolTip(`Terminus ${app.getVersion()}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
setupMenu = () => {
|
setupMenu = () => {
|
||||||
let template = [{
|
let template = [{
|
||||||
label: "Application",
|
label: "Application",
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
.terminus-logo {
|
.terminus-logo {
|
||||||
width: 160px;
|
width: 160px;
|
||||||
height: 160px;
|
height: 160px;
|
||||||
background: url('./logo.svg');
|
background: url('../assets/logo.svg');
|
||||||
background-repeat: none;
|
background-repeat: none;
|
||||||
background-size: contain;
|
background-size: contain;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
|