@@ -25,6 +25,8 @@ import {
2525import { Command , Flag } from "effect/unstable/cli" ;
2626import { ChildProcess , ChildProcessSpawner } from "effect/unstable/process" ;
2727
28+ const LINUX_ICON_SIZES = [ 16 , 22 , 24 , 32 , 48 , 64 , 128 , 256 , 512 ] as const ;
29+
2830const BuildPlatform = Schema . Literals ( [ "mac" , "linux" , "win" ] ) ;
2931const 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+
437478function 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