From a2a123ebd3fcd2962957bb4f2d89d3eb5ea0fa66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kr=C3=BChlmann?= Date: Sun, 4 Jan 2026 15:05:13 +0100 Subject: [PATCH] Customize installer --- Makefile | 4 +++ package.json | 11 +++++- shell.nix | 12 ++++--- src/main/node/app.js | 2 +- src/main/shell/run-electron-app-in-xorg | 46 +++++++++++++++++++++++++ 5 files changed, 68 insertions(+), 7 deletions(-) create mode 100755 src/main/shell/run-electron-app-in-xorg diff --git a/Makefile b/Makefile index d2cdef6..27d78d8 100644 --- a/Makefile +++ b/Makefile @@ -38,6 +38,10 @@ test: package: mvn clean package +.PHONY: runx +runx: + ./src/main/shell/run-electron-app-in-xorg + .PHONY: ssl ssl: mkdir -p local diff --git a/package.json b/package.json index b4b5e03..92f5756 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Electron wrapper for the Imgfloat overlay", "main": "app.js", "build": { - "appId": "dev.kruhlmann.imgfloat.overlay", + "appId": "dev.kruhlmann.imgfloat", "productName": "Imgfloat", "files": [ "src/main/node/app.js" ], "asar": false, @@ -18,6 +18,15 @@ "target": ["nsis"] "icon": "assets/icon/appicon.ico" }, + "nsis": { + "oneClick": true, + "perMachine": true, + "allowElevation": true, + "allowToChangeInstallationDirectory": true, + "createDesktopShortcut": true, + "createStartMenuShortcut": true, + "shortcutName": "Imgfloat" + }, "mac": { "category": "public.app-category.productivity" "icon": "assets/icon/macos.icns" diff --git a/shell.nix b/shell.nix index d049064..62ebdff 100644 --- a/shell.nix +++ b/shell.nix @@ -2,14 +2,16 @@ pkgs.mkShell { packages = [ - pkgs.openssl pkgs.electron - pkgs.openjdk - pkgs.maven - pkgs.nodejs - pkgs.nodePackages.prettier pkgs.jdt-language-server + pkgs.maven pkgs.mkcert + pkgs.nodePackages.prettier + pkgs.nodejs pkgs.nss + pkgs.openbox + pkgs.openjdk + pkgs.openssl + pkgs.xorg.xorgserver ]; } diff --git a/src/main/node/app.js b/src/main/node/app.js index d283810..1228e68 100644 --- a/src/main/node/app.js +++ b/src/main/node/app.js @@ -15,7 +15,7 @@ function createWindow() { icon: path.join(__dirname, "../resources/assets/icon/appicon.ico"), webPreferences: { backgroundThrottling: false }, }); - win.setMenu(null); + applicationWindow.setMenu(null); let canvasSizeInterval; const clearCanvasSizeInterval = () => { diff --git a/src/main/shell/run-electron-app-in-xorg b/src/main/shell/run-electron-app-in-xorg new file mode 100755 index 0000000..5fa24e8 --- /dev/null +++ b/src/main/shell/run-electron-app-in-xorg @@ -0,0 +1,46 @@ +#!/usr/bin/env sh +set -eu + +APP_ENTRY="src/main/node/app.js" +SCREEN="1280x800" + +for d in 99 98 97 96 95; do + if ! xdpyinfo -display ":$d" >/dev/null 2>&1; then + DISP="$d" + break + fi +done + +[ -n "${DISP:-}" ] || { + echo "No free DISPLAY found" >&2 + exit 1 +} + +echo "Using DISPLAY=:$DISP" + +Xephyr ":$DISP" -screen "$SCREEN" -resizeable -ac & +XEPHYR_PID=$! + +cleanup() { + kill "$ELECTRON_PID" "$OPENBOX_PID" "$XEPHYR_PID" 2>/dev/null || true +} +trap cleanup EXIT INT TERM + +sleep 1 + +DISPLAY=":$DISP" openbox & +OPENBOX_PID=$! + +sleep 0.5 + +DISPLAY=":$DISP" electron "$APP_ENTRY" & +ELECTRON_PID=$! + +# monitor X server — when it dies, kill Electron +while kill -0 "$XEPHYR_PID" 2>/dev/null; do + sleep 0.5 +done + +echo "Xephyr exited — killing Electron" +kill "$ELECTRON_PID" 2>/dev/null || true +wait "$ELECTRON_PID" 2>/dev/null || true