Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.
Rust chatgptclaudeclidesktopdesktop-appelectron-alternativegeminilinuxmacosnativefierno-electronrusttauriweb-to-desktopwebsite-to-appwebviewwindowsyoutube
fix: ship a single Linux desktop entry in deb and rpm packages
youxi798c6a054b1bba0
diff --git a/bin/builders/LinuxBuilder.ts b/bin/builders/LinuxBuilder.tsindex b13de7fc..1ddd6583 100644--- a/bin/builders/LinuxBuilder.ts+++ b/bin/builders/LinuxBuilder.ts@@ -188,18 +188,6 @@ export default class LinuxBuilder extends BaseBuilder {executable: 'tar',args: ['-xf', path.join(controlDir, dataArchive), '-C', dataDir],});- // Drop the desktop entry auto-generated by the Tauri deb bundler;- // the payload already ships Pake's own com.pake.<name>.desktop.- await fsExtra.remove(- path.join(- dataDir,- 'usr',- 'share',- 'applications',- `${packageName}.desktop`,- ),- );-const installedSize = await this.getDirectorySize(dataDir);const pkgInfo = `pkgname = ${packageName}pkgbase = ${packageName}diff --git a/bin/helpers/merge.ts b/bin/helpers/merge.tsindex 657ee004..b81d0516 100644--- a/bin/helpers/merge.ts+++ b/bin/helpers/merge.ts@@ -268,6 +268,20 @@ Terminal=false`;}+// Tauri always writes its own desktop entry into deb and rpm payloads, so+// shipping Pake's entry as an extra file left two launchers in the app menu.+// Rendering Pake's content through that single entry keeps exactly one.+export function applyLinuxDesktopTemplate(+ linuxBundle: NonNullable<PakeTauriConfig['bundle']['linux']>,+ templatePath: string,+): void {+ linuxBundle.deb.desktopTemplate = templatePath;+ if (!linuxBundle.rpm) {+ linuxBundle.rpm = {};+ }+ linuxBundle.rpm.desktopTemplate = templatePath;+}+async function mergeLinuxConfig(options: PakeAppOptions,name: string,@@ -295,17 +309,7 @@ async function mergeLinuxConfig(await fsExtra.ensureDir(srcAssetsDir);await fsExtra.writeFile(srcDesktopFilePath, desktopContent);- const desktopInstallPath = `/usr/share/applications/${desktopFileName}`;- linuxBundle.deb.files = {- [desktopInstallPath]: `assets/${desktopFileName}`,- };-- if (!linuxBundle.rpm) {- linuxBundle.rpm = {};- }- linuxBundle.rpm.files = {- [desktopInstallPath]: `assets/${desktopFileName}`,- };+ applyLinuxDesktopTemplate(linuxBundle, `assets/${desktopFileName}`);// options.targets reaches here already stripped of any -arm64 suffix by the// LinuxBuilder constructor, and may carry several comma-separated formatsdiff --git a/bin/types.ts b/bin/types.tsindex 40cf020e..c99f85bf 100644--- a/bin/types.ts+++ b/bin/types.ts@@ -238,8 +238,8 @@ export interface PakeTauriConfig {resources?: string[];targets?: string[];linux?: {- deb: { files?: Record<string, string> };- rpm?: { files?: Record<string, string> };+ deb: { files?: Record<string, string>; desktopTemplate?: string };+ rpm?: { files?: Record<string, string>; desktopTemplate?: string };[key: string]: unknown;};windows?: {diff --git a/dist/cli.js b/dist/cli.jsindex 329a1587..b3510bd5 100644--- a/dist/cli.js+++ b/dist/cli.js@@ -1112,6 +1112,16 @@ StartupWMClass=${linuxBinaryName}Terminal=false`;}+// Tauri always writes its own desktop entry into deb and rpm payloads, so+// shipping Pake's entry as an extra file left two launchers in the app menu.+// Rendering Pake's content through that single entry keeps exactly one.+function applyLinuxDesktopTemplate(linuxBundle, templatePath) {+ linuxBundle.deb.desktopTemplate = templatePath;+ if (!linuxBundle.rpm) {+ linuxBundle.rpm = {};+ }+ linuxBundle.rpm.desktopTemplate = templatePath;+}async function mergeLinuxConfig(options, name, tauriConf, linuxBinaryName) {const linuxBundle = tauriConf.bundle.linux;if (!linuxBundle) {@@ -1125,16 +1135,7 @@ async function mergeLinuxConfig(options, name, tauriConf, linuxBinaryName) {const srcDesktopFilePath = path.join(srcAssetsDir, desktopFileName);await fsExtra.ensureDir(srcAssetsDir);await fsExtra.writeFile(srcDesktopFilePath, desktopContent);- const desktopInstallPath = `/usr/share/applications/${desktopFileName}`;- linuxBundle.deb.files = {- [desktopInstallPath]: `assets/${desktopFileName}`,- };- if (!linuxBundle.rpm) {- linuxBundle.rpm = {};- }- linuxBundle.rpm.files = {- [desktopInstallPath]: `assets/${desktopFileName}`,- };+ applyLinuxDesktopTemplate(linuxBundle, `assets/${desktopFileName}`);// options.targets reaches here already stripped of any -arm64 suffix by the// LinuxBuilder constructor, and may carry several comma-separated formats// (e.g. the distro-aware default "deb,appimage"). Validate the parsed list@@ -2359,9 +2360,6 @@ class LinuxBuilder extends BaseBuilder {executable: 'tar',args: ['-xf', path.join(controlDir, dataArchive), '-C', dataDir],});- // Drop the desktop entry auto-generated by the Tauri deb bundler;- // the payload already ships Pake's own com.pake.<name>.desktop.- await fsExtra.remove(path.join(dataDir, 'usr', 'share', 'applications', `${packageName}.desktop`));const installedSize = await this.getDirectorySize(dataDir);const pkgInfo = `pkgname = ${packageName}pkgbase = ${packageName}diff --git a/tests/unit/linux-desktop.test.ts b/tests/unit/linux-desktop.test.tsindex bed41900..de25b7af 100644--- a/tests/unit/linux-desktop.test.ts+++ b/tests/unit/linux-desktop.test.ts@@ -1,6 +1,9 @@import { describe, expect, it } from 'vitest';-import { buildLinuxDesktopContent } from '../../bin/helpers/merge';+import {+ applyLinuxDesktopTemplate,+ buildLinuxDesktopContent,+} from '../../bin/helpers/merge';describe('buildLinuxDesktopContent', () => {it('uses the Tauri main binary name for freedesktop icon lookup', () => {@@ -36,3 +39,21 @@ describe('buildLinuxDesktopContent', () => {expect(desktopContent).toContain('Name[zh_CN]=妙言');});});++describe('applyLinuxDesktopTemplate', () => {+ it('renders the Pake entry through the bundler template instead of shipping a second file', () => {+ const linuxBundle: Parameters<typeof applyLinuxDesktopTemplate>[0] = {+ deb: {},+ };+ applyLinuxDesktopTemplate(linuxBundle, 'assets/com.pake.example.desktop');++ expect(linuxBundle.deb.desktopTemplate).toBe(+ 'assets/com.pake.example.desktop',+ );+ expect(linuxBundle.rpm?.desktopTemplate).toBe(+ 'assets/com.pake.example.desktop',+ );+ expect(linuxBundle.deb.files).toBeUndefined();+ expect(linuxBundle.rpm?.files).toBeUndefined();+ });+});