Skip to content

Commit

Permalink
Merge pull request #32 from th-ch/start-at-login
Browse files Browse the repository at this point in the history
Option to start at login
  • Loading branch information
th-ch authored Jul 13, 2020
2 parents eec6993 + 0fd2e7f commit 3882118
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {
isAppVisible,
isTrayEnabled,
store,
startAtLogin,
} = require("./store");
const { fileExists, injectCSS } = require("./plugins/utils");
const { isTesting } = require("./utils/testing");
Expand Down Expand Up @@ -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", () => {
Expand Down
16 changes: 16 additions & 0 deletions menu.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { app, Menu } = require("electron");
const is = require("electron-is");

const { getAllPlugins } = require("./plugins/utils");
const {
Expand All @@ -9,6 +10,7 @@ const {
isAppVisible,
isTrayEnabled,
setOptions,
startAtLogin,
} = require("./store");

const mainMenuTemplate = [
Expand Down Expand Up @@ -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: [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 7 additions & 5 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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"),
};

0 comments on commit 3882118

Please sign in to comment.