mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-14 20:01:47 +00:00
Option to start at login
This commit is contained in:
6
index.js
6
index.js
@ -12,6 +12,7 @@ const {
|
|||||||
isAppVisible,
|
isAppVisible,
|
||||||
isTrayEnabled,
|
isTrayEnabled,
|
||||||
store,
|
store,
|
||||||
|
startAtLogin,
|
||||||
} = require("./store");
|
} = require("./store");
|
||||||
const { fileExists, injectCSS } = require("./plugins/utils");
|
const { fileExists, injectCSS } = require("./plugins/utils");
|
||||||
const { isTesting } = require("./utils/testing");
|
const { isTesting } = require("./utils/testing");
|
||||||
@ -170,6 +171,11 @@ app.on("ready", () => {
|
|||||||
mainWindow = createMainWindow();
|
mainWindow = createMainWindow();
|
||||||
setUpTray(app, mainWindow);
|
setUpTray(app, mainWindow);
|
||||||
|
|
||||||
|
// Autostart at login
|
||||||
|
app.setLoginItemSettings({
|
||||||
|
openAtLogin: startAtLogin(),
|
||||||
|
});
|
||||||
|
|
||||||
if (!is.dev() && autoUpdate()) {
|
if (!is.dev() && autoUpdate()) {
|
||||||
autoUpdater.checkForUpdatesAndNotify();
|
autoUpdater.checkForUpdatesAndNotify();
|
||||||
autoUpdater.on("update-available", () => {
|
autoUpdater.on("update-available", () => {
|
||||||
|
|||||||
16
menu.js
16
menu.js
@ -1,4 +1,5 @@
|
|||||||
const { app, Menu } = require("electron");
|
const { app, Menu } = require("electron");
|
||||||
|
const is = require("electron-is");
|
||||||
|
|
||||||
const { getAllPlugins } = require("./plugins/utils");
|
const { getAllPlugins } = require("./plugins/utils");
|
||||||
const {
|
const {
|
||||||
@ -9,6 +10,7 @@ const {
|
|||||||
isAppVisible,
|
isAppVisible,
|
||||||
isTrayEnabled,
|
isTrayEnabled,
|
||||||
setOptions,
|
setOptions,
|
||||||
|
startAtLogin,
|
||||||
} = require("./store");
|
} = require("./store");
|
||||||
|
|
||||||
const mainMenuTemplate = [
|
const mainMenuTemplate = [
|
||||||
@ -40,6 +42,20 @@ const mainMenuTemplate = [
|
|||||||
setOptions({ autoUpdates: item.checked });
|
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",
|
label: "Tray",
|
||||||
submenu: [
|
submenu: [
|
||||||
|
|||||||
@ -5,16 +5,17 @@ const store = new Store({
|
|||||||
defaults: {
|
defaults: {
|
||||||
"window-size": {
|
"window-size": {
|
||||||
width: 1100,
|
width: 1100,
|
||||||
height: 550
|
height: 550,
|
||||||
},
|
},
|
||||||
url: "https://music.youtube.com",
|
url: "https://music.youtube.com",
|
||||||
plugins: ["navigation", "shortcuts", "adblocker"],
|
plugins: ["navigation", "shortcuts", "adblocker"],
|
||||||
options: {
|
options: {
|
||||||
tray: false,
|
tray: false,
|
||||||
appVisible: true,
|
appVisible: true,
|
||||||
autoUpdates: true
|
autoUpdates: true,
|
||||||
}
|
startAtLogin: false,
|
||||||
}
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@ -29,5 +30,6 @@ module.exports = {
|
|||||||
store.set("options", { ...store.get("options"), ...options }),
|
store.set("options", { ...store.get("options"), ...options }),
|
||||||
isTrayEnabled: () => store.get("options.tray"),
|
isTrayEnabled: () => store.get("options.tray"),
|
||||||
isAppVisible: () => store.get("options.appVisible"),
|
isAppVisible: () => store.get("options.appVisible"),
|
||||||
autoUpdate: () => store.get("options.autoUpdates")
|
autoUpdate: () => store.get("options.autoUpdates"),
|
||||||
|
startAtLogin: () => store.get("options.startAtLogin"),
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user