Skip to content

Commit

Permalink
added the ability to set custom app icons for windows / macos
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jSdCool committed Nov 23, 2023
1 parent 6a2cf8c commit d3367d1
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions java/src/processing/mode/java/JavaBuild.java
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,18 @@ protected boolean exportApplication(File destFolder,
File resourcesFolder = new File(contentsFolder, "Resources");
Util.copyDir(new File(contentsOrig, "Resources/en.lproj"),
new File(resourcesFolder, "en.lproj"));
Util.copyFile(mode.getContentFile("application/application.icns"),

Settings sketchProperties = new Settings(new File(sketch.getFolder(), "sketch.properties"));
String iconPath = sketchProperties.get("icon");//icon.macos
File iconFile;
if(iconPath == null || iconPath.isEmpty()){
iconFile = mode.getContentFile("application/application.icns");
System.out.println("using default icon");
}else {
iconFile = new File(sketch.getFolder(), iconPath);
System.out.println("found custom icon: "+iconPath);
}
Util.copyFile(iconFile,
new File(resourcesFolder, "application.icns"));

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

File iconFile = mode.getContentFile("application/application.ico");
//check sketch.properties to see if an icon was set
Settings sketchProperties = new Settings(new File(sketch.getFolder(), "sketch.properties"));
String iconPath = sketchProperties.get("icon");//icon.windows
File iconFile;
if(iconPath == null || iconPath.isEmpty()){
iconFile = mode.getContentFile("application/application.ico");
System.out.println("using default icon");
}else {
iconFile = new File(sketch.getFolder(), iconPath);
System.out.println("found custom icon: "+iconPath);
}
config.addChild("icon").setContent(iconFile.getAbsolutePath());

XML clazzPath = config.addChild("classPath");
Expand Down

0 comments on commit d3367d1

Please sign in to comment.