Skip to content

Commit d3367d1

Browse files
committed
added the ability to set custom app icons for windows / macos
simply add a line in sketch.properties icon.windows= or icon.macos= folow the = with the relative path to the icon file that you wish to use
1 parent 6a2cf8c commit d3367d1

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

java/src/processing/mode/java/JavaBuild.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,18 @@ protected boolean exportApplication(File destFolder,
735735
File resourcesFolder = new File(contentsFolder, "Resources");
736736
Util.copyDir(new File(contentsOrig, "Resources/en.lproj"),
737737
new File(resourcesFolder, "en.lproj"));
738-
Util.copyFile(mode.getContentFile("application/application.icns"),
738+
739+
Settings sketchProperties = new Settings(new File(sketch.getFolder(), "sketch.properties"));
740+
String iconPath = sketchProperties.get("icon");//icon.macos
741+
File iconFile;
742+
if(iconPath == null || iconPath.isEmpty()){
743+
iconFile = mode.getContentFile("application/application.icns");
744+
System.out.println("using default icon");
745+
}else {
746+
iconFile = new File(sketch.getFolder(), iconPath);
747+
System.out.println("found custom icon: "+iconPath);
748+
}
749+
Util.copyFile(iconFile,
739750
new File(resourcesFolder, "application.icns"));
740751

741752
} else if (exportPlatform == PConstants.LINUX) {
@@ -958,7 +969,17 @@ protected boolean exportApplication(File destFolder,
958969
File exeFile = new File(destFolder, sketch.getName() + ".exe");
959970
config.addChild("outfile").setContent(exeFile.getAbsolutePath());
960971

961-
File iconFile = mode.getContentFile("application/application.ico");
972+
//check sketch.properties to see if an icon was set
973+
Settings sketchProperties = new Settings(new File(sketch.getFolder(), "sketch.properties"));
974+
String iconPath = sketchProperties.get("icon");//icon.windows
975+
File iconFile;
976+
if(iconPath == null || iconPath.isEmpty()){
977+
iconFile = mode.getContentFile("application/application.ico");
978+
System.out.println("using default icon");
979+
}else {
980+
iconFile = new File(sketch.getFolder(), iconPath);
981+
System.out.println("found custom icon: "+iconPath);
982+
}
962983
config.addChild("icon").setContent(iconFile.getAbsolutePath());
963984

964985
XML clazzPath = config.addChild("classPath");

0 commit comments

Comments
 (0)