Skip to content

Commit 353fee9

Browse files
committed
fix(desktop): include standard Linux AppImage icons
1 parent ada410b commit 353fee9

2 files changed

Lines changed: 70 additions & 14 deletions

File tree

.github/workflows/release.yml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,32 @@ jobs:
232232
shell: pwsh
233233
run: |
234234
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
235-
$installPath = & $vswhere -products * -latest -property installationPath
236-
$setupExe = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\setup.exe"
237-
$proc = Start-Process -FilePath $setupExe `
238-
-ArgumentList "modify", "--installPath", "`"$installPath`"", "--add", `
239-
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64.Spectre", "--quiet", "--norestart" `
240-
-Wait -PassThru -NoNewWindow
241-
if ($null -eq $proc -or $proc.ExitCode -ne 0) {
242-
$code = if ($null -ne $proc) { $proc.ExitCode } else { 1 }
243-
Write-Error "Visual Studio Installer failed with exit code $code"
244-
exit $code
245-
}
235+
$installPath = & $vswhere -products * -latest -property installationPath
236+
$setupExe = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\setup.exe"
237+
$proc = Start-Process -FilePath $setupExe `
238+
-ArgumentList "modify", "--installPath", "`"$installPath`"", "--add", `
239+
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64.Spectre", "--quiet", "--norestart" `
240+
-Wait -PassThru -NoNewWindow
241+
if ($null -eq $proc -or $proc.ExitCode -ne 0) {
242+
$code = if ($null -ne $proc) { $proc.ExitCode } else { 1 }
243+
Write-Error "Visual Studio Installer failed with exit code $code"
244+
exit $code
245+
}
246+
247+
- name: Install ImageMagick
248+
if: matrix.platform == 'linux'
249+
shell: bash
250+
run: |
251+
if ! command -v magick >/dev/null 2>&1 && ! command -v convert >/dev/null 2>&1; then
252+
sudo apt-get update
253+
sudo apt-get install -y imagemagick
254+
fi
255+
256+
if command -v magick >/dev/null 2>&1; then
257+
magick -version
258+
else
259+
convert -version
260+
fi
246261
247262
- name: Build desktop artifact
248263
shell: bash

scripts/build-desktop-artifact.ts

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import {
2525
import { Command, Flag } from "effect/unstable/cli";
2626
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
2727

28+
const LINUX_ICON_SIZES = [16, 22, 24, 32, 48, 64, 128, 256, 512] as const;
29+
2830
const BuildPlatform = Schema.Literals(["mac", "linux", "win"]);
2931
const BuildArch = Schema.Literals(["arm64", "x64", "universal"]);
3032

@@ -419,7 +421,7 @@ function stageMacIcons(stageResourcesDir: string, sourcePng: string, verbose: bo
419421
});
420422
}
421423

422-
function stageLinuxIcons(stageResourcesDir: string, sourcePng: string) {
424+
function stageLinuxIcons(stageResourcesDir: string, sourcePng: string, verbose: boolean) {
423425
return Effect.gen(function* () {
424426
const fs = yield* FileSystem.FileSystem;
425427
const path = yield* Path.Path;
@@ -431,9 +433,48 @@ function stageLinuxIcons(stageResourcesDir: string, sourcePng: string) {
431433

432434
const iconPath = path.join(stageResourcesDir, "icon.png");
433435
yield* fs.copyFile(sourcePng, iconPath);
436+
437+
const iconsDir = path.join(stageResourcesDir, "icons");
438+
yield* fs.makeDirectory(iconsDir, { recursive: true });
439+
for (const iconSize of LINUX_ICON_SIZES) {
440+
yield* stageLinuxIconSize(
441+
sourcePng,
442+
path.join(iconsDir, `${iconSize}x${iconSize}.png`),
443+
iconSize,
444+
verbose,
445+
);
446+
}
434447
});
435448
}
436449

450+
function stageLinuxIconSize(
451+
sourcePng: string,
452+
targetPng: string,
453+
iconSize: number,
454+
verbose: boolean,
455+
) {
456+
const resize = (command: string) =>
457+
runCommand(
458+
ChildProcess.make(command, [sourcePng, "-resize", `${iconSize}x${iconSize}`, targetPng], {
459+
...commandOutputOptions(verbose),
460+
}),
461+
);
462+
463+
return resize("magick").pipe(
464+
Effect.catch(() =>
465+
resize("convert").pipe(
466+
Effect.mapError(
467+
() =>
468+
new BuildScriptError({
469+
message:
470+
"ImageMagick is required to generate Linux desktop icon sizes. Install ImageMagick so either `magick` or `convert` is available.",
471+
}),
472+
),
473+
),
474+
),
475+
);
476+
}
477+
437478
function stageWindowsIcons(stageResourcesDir: string, sourceIco: string) {
438479
return Effect.gen(function* () {
439480
const fs = yield* FileSystem.FileSystem;
@@ -599,7 +640,7 @@ const createBuildConfig = Effect.fn("createBuildConfig")(function* (
599640
buildConfig.linux = {
600641
target: [target],
601642
executableName: "t3code",
602-
icon: "icon.png",
643+
icon: "icons",
603644
category: "Development",
604645
desktop: {
605646
entry: {
@@ -638,7 +679,7 @@ const assertPlatformBuildResources = Effect.fn("assertPlatformBuildResources")(f
638679
}
639680

640681
if (platform === "linux") {
641-
yield* stageLinuxIcons(stageResourcesDir, iconAssets.linuxIconPng);
682+
yield* stageLinuxIcons(stageResourcesDir, iconAssets.linuxIconPng, verbose);
642683
return;
643684
}
644685

0 commit comments

Comments
 (0)