From 408aa9bb598fa8e8e427b8e8dd2232e863e91e91 Mon Sep 17 00:00:00 2001 From: TC Date: Sun, 12 Jul 2020 21:05:34 +0200 Subject: [PATCH 1/2] Option to start at login --- index.js | 6 ++++++ menu.js | 16 ++++++++++++++++ store/index.js | 12 +++++++----- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 0c32a9f913..9942ad1b9c 100644 --- a/index.js +++ b/index.js @@ -12,6 +12,7 @@ const { isAppVisible, isTrayEnabled, store, + startAtLogin, } = require("./store"); const { fileExists, injectCSS } = require("./plugins/utils"); const { isTesting } = require("./utils/testing"); @@ -170,6 +171,11 @@ app.on("ready", () => { mainWindow = createMainWindow(); setUpTray(app, mainWindow); + // Autostart at login + app.setLoginItemSettings({ + openAtLogin: startAtLogin(), + }); + if (!is.dev() && autoUpdate()) { autoUpdater.checkForUpdatesAndNotify(); autoUpdater.on("update-available", () => { diff --git a/menu.js b/menu.js index 6f9e68366e..e18b9bd007 100644 --- a/menu.js +++ b/menu.js @@ -1,4 +1,5 @@ const { app, Menu } = require("electron"); +const is = require("electron-is"); const { getAllPlugins } = require("./plugins/utils"); const { @@ -9,6 +10,7 @@ const { isAppVisible, isTrayEnabled, setOptions, + startAtLogin, } = require("./store"); const mainMenuTemplate = [ @@ -40,6 +42,20 @@ const mainMenuTemplate = [ setOptions({ autoUpdates: item.checked }); }, }, + ...(is.windows() || is.macOS() + ? // Only works on Win/Mac + // https://www.electronjs.org/docs/api/app#appsetloginitemsettingssettings-macos-windows + [ + { + label: "Start at login", + type: "checkbox", + checked: startAtLogin(), + click: (item) => { + setOptions({ startAtLogin: item.checked }); + }, + }, + ] + : []), { label: "Tray", submenu: [ diff --git a/store/index.js b/store/index.js index 4ae9af01ab..703b4d8343 100644 --- a/store/index.js +++ b/store/index.js @@ -5,16 +5,17 @@ const store = new Store({ defaults: { "window-size": { width: 1100, - height: 550 + height: 550, }, url: "https://music.youtube.com", plugins: ["navigation", "shortcuts", "adblocker"], options: { tray: false, appVisible: true, - autoUpdates: true - } - } + autoUpdates: true, + startAtLogin: false, + }, + }, }); module.exports = { @@ -29,5 +30,6 @@ module.exports = { store.set("options", { ...store.get("options"), ...options }), isTrayEnabled: () => store.get("options.tray"), isAppVisible: () => store.get("options.appVisible"), - autoUpdate: () => store.get("options.autoUpdates") + autoUpdate: () => store.get("options.autoUpdates"), + startAtLogin: () => store.get("options.startAtLogin"), }; From 0fd2e7f51c219c735701a98be727aeb7786bbff4 Mon Sep 17 00:00:00 2001 From: TC Date: Sun, 12 Jul 2020 21:09:03 +0200 Subject: [PATCH 2/2] Bump version to 1.4.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 36b241a6d1..efb4d53a87 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "youtube-music", "productName": "YouTube Music", - "version": "1.3.3", + "version": "1.4.0", "description": "YouTube Music Desktop App - including custom plugins", "license": "MIT", "repository": "th-ch/youtube-music",