mirror of
https://github.com/ollama/ollama.git
synced 2025-05-07 21:00:22 +02:00
add app to open at login by default
This commit is contained in:
parent
8b57e715a7
commit
bc54daf2bc
@ -1,5 +1,6 @@
|
|||||||
import { spawn, exec } from 'child_process'
|
import { spawn, exec } from 'child_process'
|
||||||
import { app, autoUpdater, dialog, Tray, Menu } from 'electron'
|
import { app, autoUpdater, dialog, Tray, Menu } from 'electron'
|
||||||
|
import Store from 'electron-store'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
|
|
||||||
@ -7,6 +8,8 @@ import { analytics, id } from './telemetry'
|
|||||||
|
|
||||||
require('@electron/remote/main').initialize()
|
require('@electron/remote/main').initialize()
|
||||||
|
|
||||||
|
|
||||||
|
const store = new Store();
|
||||||
let tray: Tray | null = null
|
let tray: Tray | null = null
|
||||||
|
|
||||||
const SingleInstanceLock = app.requestSingleInstanceLock()
|
const SingleInstanceLock = app.requestSingleInstanceLock()
|
||||||
@ -23,7 +26,9 @@ const createSystemtray = () => {
|
|||||||
|
|
||||||
tray = new Tray(iconPath)
|
tray = new Tray(iconPath)
|
||||||
|
|
||||||
const contextMenu = Menu.buildFromTemplate([{ role: 'quit', label: 'Quit Ollama', accelerator: 'Command+Q' }])
|
const contextMenu = Menu.buildFromTemplate([
|
||||||
|
{ role: 'quit', label: 'Quit Ollama', accelerator: 'Command+Q' }
|
||||||
|
])
|
||||||
|
|
||||||
tray.setContextMenu(contextMenu)
|
tray.setContextMenu(contextMenu)
|
||||||
tray.setToolTip('Ollama')
|
tray.setToolTip('Ollama')
|
||||||
@ -107,6 +112,15 @@ app.on('ready', () => {
|
|||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
app.dock.hide()
|
app.dock.hide()
|
||||||
|
|
||||||
|
if (!store.has('first-time-run')) {
|
||||||
|
// This is the first run
|
||||||
|
app.setLoginItemSettings({ openAtLogin: true })
|
||||||
|
store.set('first-time-run', false);
|
||||||
|
} else {
|
||||||
|
// The app has been run before
|
||||||
|
app.setLoginItemSettings({ openAtLogin: app.getLoginItemSettings().openAtLogin })
|
||||||
|
}
|
||||||
|
|
||||||
if (!app.isInApplicationsFolder()) {
|
if (!app.isInApplicationsFolder()) {
|
||||||
const chosen = dialog.showMessageBoxSync({
|
const chosen = dialog.showMessageBoxSync({
|
||||||
type: 'question',
|
type: 'question',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user