Skip to content

Commit

Permalink
Merge pull request #5 from D0rkKnight/macos
Browse files Browse the repository at this point in the history
App is launching on mac
  • Loading branch information
shouhanzen authored Dec 28, 2023
2 parents 6a67583 + 0702996 commit c8bab4a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ venv: ## make virtual environment (activate with `source venv/Scripts/activate

onefolder:
onefolder: ## make pyinstaller exe within folder of dependencies
rm -rf dist/*
$(PYINSTALLER) $(CLEAN) $(OUTPUT_NAME) $(ICON) $(EXTRA_HOOKS) $(MAIN_FILE)
cp -r public ./dist/$(FILENAME)/public

Expand Down
17 changes: 13 additions & 4 deletions frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ process.on('uncaughtException', (error) => {

// Keep a global reference of the window object to avoid it being garbage collected.
let win;
const SHORTCUT = 'Ctrl+Shift+Alt+P';
const SHORTCUT = () => {
if (process.platform == "win32") return 'Ctrl+Shift+Alt+P';
if (process.platform == "darwin") return 'Option+Shift+P';
return 'Unknown OS';
};
let backendProcess = null;

const appServe = app.isPackaged ? serve({
Expand Down Expand Up @@ -92,7 +96,12 @@ function tryStartBackend(win) {
let backendPath = "";

let root = path.join(app.getAppPath(), "..", "..");
backendPath = path.join(root, "backend", "backend_0p1.exe"); // Use double backslashes for Windows paths
let backend_executable = "backend_0p1.exe";

if (process.platform == "darwin")
backend_executable = "backend_0p1";

backendPath = path.join(root, "backend", backend_executable); // Use double backslashes for Windows paths

// Use execFile
// Define the backend executable and the arguments
Expand Down Expand Up @@ -182,7 +191,7 @@ app.whenReady().then(() => {
createWindow()

// Register a global shortcut listener.
const ret = globalShortcut.register(SHORTCUT, () => {
const ret = globalShortcut.register(SHORTCUT(), () => {
toggleWindow();
});

Expand All @@ -191,7 +200,7 @@ app.whenReady().then(() => {
}

// Check whether a shortcut is registered.
console.log(globalShortcut.isRegistered(SHORTCUT));
console.log(globalShortcut.isRegistered(SHORTCUT()));
});

// Quit when all windows are closed.
Expand Down

0 comments on commit c8bab4a

Please sign in to comment.