-
Notifications
You must be signed in to change notification settings - Fork 557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start in tray #18
Comments
The following codes will give you trayconst path = require('path');
const trayIcon = path.join(__dirname, 'assets/icon.ico');
//const trayIcon = nativeImage.createFromPath("./assets/icon.png");
app.on("ready", () => {
tray = new Tray(trayIcon)
const contextMenu = Menu.buildFromTemplate([
{
label: 'Play/Pause', click: function () {
hook_ytm("#left-controls > div > paper-icon-button.play-pause-button.style-scope.ytmusic-player-bar")
}
},
{
label: 'Next', click: function () {
hook_ytm("#left-controls > div > paper-icon-button.next-button.style-scope.ytmusic-player-bar")
}
},
{
label: 'Prev', click: function () {
hook_ytm("#left-controls > div > paper-icon-button.previous-button.style-scope.ytmusic-player-bar")
}
},
{
label: 'Show', click: function () {
win.show()
}
},
{
label: 'Quit', click: function () {
app.quit()
}
},
])
tray.setToolTip('Youtube Music')
tray.on('double-click', () => {
win.show()
})
if (process.platform == 'win32') {
tray.on('click', tray.popUpContextMenu)
}
tray.setContextMenu(contextMenu);
createWindow();
}
)
// bla bla bla
async function createWindow() {
win = new BrowserWindow({
backgroundColor: "#000",
webPreferences: { nodeIntegration: false, contextIsolation: true },
// bla bla bla
})
win.on('close', (event) => {
if (app.quitting) {
win = null
} else {
if (process.platform == 'darwin') {
app.dock.hide()
}
event.preventDefault()
win.hide()
}
})
await win.loadURL('https://music.youtube.com')
return win;
}
function hook_ytm(selector) {
win.webContents.executeJavaScript('document.querySelector("' + selector + '").click();', true)
} |
Hey @fernandogobah , thanks for submitting the issue! The latest version (v1.3.1) has an "options" menu, you can enable tray and set the window visible or hidden - with "Tray + hidden window", you should have the behavior "start in tray". Feel free to re-open this issue if it does not work properly! PS: Thank you @subratappt for the code snippet, it has been implemented in the app! |
Thank you for the implementation. Version: 1.3.1
|
Hey @subratappt, thanks for reporting both issues! v1.3.2 should fix issue 1, the app should now not exit if the tray is on (unless you select "Quit" in the tray menu) + clicking on the tray icon should now show/hide the app. For the second issue, |
Thank you for the update. Yes for the second issue, "autoconfirm when paused" was enabled. I hope you will get the issue solved soon. |
Is it possible to add auto start when you turn on the computer? |
Hey @benji009, thank you for the feedback! #32 adds an option to autostart the application at login (YouTube Music then starts playing automatically) which is available in the 1.4.0 pre-release but only works for Mac/Win (limitation of electron), would this do the job for you? |
yes that is perfect :) |
It seems the last open problem in this issue is the auto-confirm-when-paused vs media keys - it seems it is fixed in the last versions but in case it's not, it will be tracked in #129 - closing this one, feel free to re-open/open a new issue if needed! |
Is possible start the app in tray bar?
The text was updated successfully, but these errors were encountered: