diff --git a/build/Assets.car b/build/Assets.car new file mode 100644 index 0000000..60c0fe0 Binary files /dev/null and b/build/Assets.car differ diff --git a/build/background.tiff b/build/background.tiff index a0e3f7f..1306d07 100644 Binary files a/build/background.tiff and b/build/background.tiff differ diff --git a/build/icon.icns b/build/icon.icns index 34d8371..6b3e94f 100644 Binary files a/build/icon.icns and b/build/icon.icns differ diff --git a/build/icon.ico b/build/icon.ico new file mode 100644 index 0000000..9e06b43 Binary files /dev/null and b/build/icon.ico differ diff --git a/build/icon.png b/build/icon.png deleted file mode 100644 index 027ab0b..0000000 Binary files a/build/icon.png and /dev/null differ diff --git a/build/icon.svg b/build/icon.svg new file mode 100644 index 0000000..3bcbd11 --- /dev/null +++ b/build/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/package.json b/package.json index 771a25f..24533e3 100644 --- a/package.json +++ b/package.json @@ -79,9 +79,10 @@ "discord" ] }, - "beforePack": "scripts/build/sandboxFix.js", + "beforePack": "scripts/build/beforePack.mjs", + "afterPack": "scripts/build/afterPack.mjs", "linux": { - "icon": "build/icon.icns", + "icon": "build/icon.svg", "category": "Network", "maintainer": "vendicated+vesktop@riseup.net", "target": [ @@ -141,7 +142,8 @@ "NSMicrophoneUsageDescription": "This app needs access to the microphone", "NSCameraUsageDescription": "This app needs access to the camera", "com.apple.security.device.audio-input": true, - "com.apple.security.device.camera": true + "com.apple.security.device.camera": true, + "CFBundleIconName": "Icon" }, "notarize": true }, @@ -171,6 +173,7 @@ "oneClick": false }, "win": { + "icon": "build/icon.ico", "target": [ { "target": "nsis", diff --git a/scripts/build/addAssetsCar.mjs b/scripts/build/addAssetsCar.mjs new file mode 100644 index 0000000..123b61b --- /dev/null +++ b/scripts/build/addAssetsCar.mjs @@ -0,0 +1,24 @@ +import { copyFile, readdir } from "fs/promises"; + +/** + * @param {{ + * readonly appOutDir: string; + * readonly arch: Arch; + * readonly electronPlatformName: string; + * readonly outDir: string; + * readonly packager: PlatformPackager; + * readonly targets: Target[]; + * }} context + */ +export async function addAssetsCar({ appOutDir }) { + if (process.platform !== "darwin") return; + + const appName = (await readdir(appOutDir)).find(item => item.endsWith(".app")); + + if (!appName) { + console.warn(`Could not find .app directory in ${appOutDir}. Skipping adding assets.car`); + return; + } + + await copyFile("build/Assets.car", `${appOutDir}/${appName}/Contents/Resources/Assets.car`); +} diff --git a/scripts/build/afterPack.mjs b/scripts/build/afterPack.mjs new file mode 100644 index 0000000..6a446d6 --- /dev/null +++ b/scripts/build/afterPack.mjs @@ -0,0 +1,5 @@ +import { addAssetsCar } from "./addAssetsCar.mjs"; + +export default async function afterPack(context) { + await addAssetsCar(context); +} diff --git a/scripts/build/beforePack.mjs b/scripts/build/beforePack.mjs new file mode 100644 index 0000000..5b1fa38 --- /dev/null +++ b/scripts/build/beforePack.mjs @@ -0,0 +1,5 @@ +import { applyAppImageSandboxFix } from "./sandboxFix.mjs"; + +export default async function beforePack() { + await applyAppImageSandboxFix(); +} diff --git a/scripts/build/sandboxFix.js b/scripts/build/sandboxFix.mjs similarity index 91% rename from scripts/build/sandboxFix.js rename to scripts/build/sandboxFix.mjs index ff04732..03f92e4 100644 --- a/scripts/build/sandboxFix.js +++ b/scripts/build/sandboxFix.mjs @@ -6,18 +6,21 @@ // Based on https://github.com/gergof/electron-builder-sandbox-fix/blob/master/lib/index.js -const fs = require("fs/promises"); -const path = require("path"); +import fs from "fs/promises"; +import path from "path"; +import AppImageTarget from "app-builder-lib/out/targets/AppImageTarget.js"; + let isApplied = false; -const hook = async () => { - if (isApplied) return; - isApplied = true; +export async function applyAppImageSandboxFix() { if (process.platform !== "linux") { // this fix is only required on linux return; } - const AppImageTarget = require("app-builder-lib/out/targets/AppImageTarget"); + + if (isApplied) return; + isApplied = true; + const oldBuildMethod = AppImageTarget.default.prototype.build; AppImageTarget.default.prototype.build = async function (...args) { console.log("Running AppImage builder hook", args); @@ -69,6 +72,4 @@ exec "$SCRIPT_DIR/${this.packager.executableName}.bin" "$([ "$IS_STEAMOS" == 1 ] return ret; }; -}; - -module.exports = hook; +} diff --git a/src/main/about.ts b/src/main/about.ts index bed2f34..3e3e5f0 100644 --- a/src/main/about.ts +++ b/src/main/about.ts @@ -6,7 +6,7 @@ import { app, BrowserWindow } from "electron"; import { join } from "path"; -import { ICON_PATH, VIEW_DIR } from "shared/paths"; +import { VIEW_DIR } from "shared/paths"; import { makeLinksOpenExternally } from "./utils/makeLinksOpenExternally"; @@ -17,7 +17,6 @@ export async function createAboutWindow() { const about = new BrowserWindow({ center: true, autoHideMenuBar: true, - icon: ICON_PATH, height, width }); diff --git a/src/main/firstLaunch.ts b/src/main/firstLaunch.ts index 69e01a0..4ba335a 100644 --- a/src/main/firstLaunch.ts +++ b/src/main/firstLaunch.ts @@ -9,7 +9,7 @@ import { BrowserWindow } from "electron/main"; import { copyFileSync, mkdirSync, readdirSync } from "fs"; import { join } from "path"; import { SplashProps } from "shared/browserWinProperties"; -import { ICON_PATH, VIEW_DIR } from "shared/paths"; +import { VIEW_DIR } from "shared/paths"; import { autoStart } from "./autoStart"; import { DATA_DIR } from "./constants"; @@ -32,8 +32,7 @@ export function createFirstLaunchTour() { frame: true, autoHideMenuBar: true, height: 470, - width: 550, - icon: ICON_PATH + width: 550 }); makeLinksOpenExternally(win); diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 762d39b..2f772c2 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -24,7 +24,7 @@ import { isTruthy } from "shared/utils/guards"; import { once } from "shared/utils/once"; import type { SettingsStore } from "shared/utils/SettingsStore"; -import { ICON_PATH } from "../shared/paths"; +import { TRAY_ICON_PATH } from "../shared/paths"; import { createAboutWindow } from "./about"; import { initArRPC } from "./arrpc"; import { @@ -126,7 +126,7 @@ function initTray(win: BrowserWindow) { } ]); - tray = new Tray(ICON_PATH); + tray = new Tray(join(TRAY_ICON_PATH, `${process.platform === "darwin" ? "trayTemplate" : "tray"}.png`)); tray.setToolTip("Vesktop"); tray.setContextMenu(trayMenu); tray.on("click", onTrayClick); @@ -439,7 +439,6 @@ function createMainWindow() { // disable renderer backgrounding to prevent the app from unloading when in the background backgroundThrottling: false }, - icon: ICON_PATH, frame: !noFrame, ...(transparent && { transparent: true, diff --git a/src/main/splash.ts b/src/main/splash.ts index d9f39bd..1b9b972 100644 --- a/src/main/splash.ts +++ b/src/main/splash.ts @@ -7,7 +7,7 @@ import { BrowserWindow } from "electron"; import { join } from "path"; import { SplashProps } from "shared/browserWinProperties"; -import { ICON_PATH, VIEW_DIR } from "shared/paths"; +import { VIEW_DIR } from "shared/paths"; import { Settings } from "./settings"; @@ -16,7 +16,6 @@ let splash: BrowserWindow | undefined; export function createSplashWindow(startMinimized = false) { splash = new BrowserWindow({ ...SplashProps, - icon: ICON_PATH, show: !startMinimized, webPreferences: { preload: join(__dirname, "splashPreload.js") diff --git a/src/shared/paths.ts b/src/shared/paths.ts index a935d82..ba2b537 100644 --- a/src/shared/paths.ts +++ b/src/shared/paths.ts @@ -9,4 +9,4 @@ import { join } from "path"; export const STATIC_DIR = /* @__PURE__ */ join(__dirname, "..", "..", "static"); export const VIEW_DIR = /* @__PURE__ */ join(STATIC_DIR, "views"); export const BADGE_DIR = /* @__PURE__ */ join(STATIC_DIR, "badges"); -export const ICON_PATH = /* @__PURE__ */ join(STATIC_DIR, "icon.png"); +export const TRAY_ICON_PATH = /* @__PURE__ */ join(STATIC_DIR, "tray"); diff --git a/static/icon.ico b/static/icon.ico deleted file mode 100644 index 1dc9894..0000000 Binary files a/static/icon.ico and /dev/null differ diff --git a/static/icon.png b/static/icon.png deleted file mode 100644 index 027ab0b..0000000 Binary files a/static/icon.png and /dev/null differ diff --git a/static/tray/badge.png b/static/tray/badge.png new file mode 100644 index 0000000..4af928c Binary files /dev/null and b/static/tray/badge.png differ diff --git a/static/tray/tray.png b/static/tray/tray.png new file mode 100644 index 0000000..f4b80d6 Binary files /dev/null and b/static/tray/tray.png differ diff --git a/static/tray/trayTemplate.png b/static/tray/trayTemplate.png new file mode 100644 index 0000000..6a34cf6 Binary files /dev/null and b/static/tray/trayTemplate.png differ