Skip to content

Commit 41f4599

Browse files
committed
pass image from updater to jar
1 parent 1548da5 commit 41f4599

File tree

1 file changed

+32
-29
lines changed

1 file changed

+32
-29
lines changed

CaDoodleUpdater/src/main/java/com/commonwealthrobotics/JvmManager.java

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,17 @@ public static String getCommandString(String project, String repo, String versio
121121
}
122122
String cmd = bindir + name + "/bin/java" + (CadoodleUpdater.isWin() ? ".exe" : "") + " ";
123123
// Mac OS set the dock icon
124-
// String iconPath = extractIconToTemp();
125-
// if (iconPath != null) {
126-
// if(CadoodleUpdater.isMac()) {
127-
// cmd += "-Xdock:icon=" + iconPath + " ";
128-
// cmd += "-Xdock:name=CADoodle ";
129-
// }
130-
// }
124+
String iconPath = extractIconToTemp();
125+
if (iconPath != null) {
126+
if (CadoodleUpdater.isMac()) {
127+
cmd += "-Xdock:icon=" + iconPath + " ";
128+
cmd += "-Xdock:name=CADoodle ";
129+
}
130+
if (CadoodleUpdater.isLin()) {
131+
cmd += "-Dcadoodle.icon.path=" + iconPath + " ";
132+
cmd += "-Dglass.gtk.wmclass=CaDoodle ";
133+
}
134+
}
131135
for (String s : jvmargs) {
132136
cmd += s + " ";
133137
}
@@ -140,25 +144,26 @@ public static String getCommandString(String project, String repo, String versio
140144
}
141145
return null;
142146
}
147+
143148
private static String extractIconToTemp() {
144-
try {
145-
// Create temp file for icon
146-
Path tempIcon = Files.createTempFile("cadoodle-icon", ".png");
147-
tempIcon.toFile().deleteOnExit();
148-
149-
// Extract icon from resources (adjust path as needed)
150-
try (InputStream in =Main.class.getResourceAsStream("CADoodle-Icon.png")) {
151-
if (in != null) {
152-
Files.copy(in, tempIcon, StandardCopyOption.REPLACE_EXISTING);
153-
return tempIcon.toAbsolutePath().toString();
154-
}
155-
}
156-
} catch (Exception e) {
157-
e.printStackTrace();
158-
}
159-
return null;
149+
try {
150+
// Create temp file for icon
151+
Path tempIcon = Files.createTempFile("cadoodle-icon", ".png");
152+
tempIcon.toFile().deleteOnExit();
153+
154+
// Extract icon from resources (adjust path as needed)
155+
try (InputStream in = Main.class.getResourceAsStream("CADoodle-Icon.png")) {
156+
if (in != null) {
157+
Files.copy(in, tempIcon, StandardCopyOption.REPLACE_EXISTING);
158+
return tempIcon.toAbsolutePath().toString();
159+
}
160+
}
161+
} catch (Exception e) {
162+
e.printStackTrace();
163+
}
164+
return null;
160165
}
161-
166+
162167
private static String discoverKey(String key) {
163168
if (CadoodleUpdater.isLin()) {
164169
if (CadoodleUpdater.isArm()) {
@@ -297,17 +302,15 @@ public static long getRemoteSize(String url) throws IOException {
297302
private static File download(String version, String downloadURL, ProgressBar progressBar, Label progressLabel,
298303
String bindir, String filename) throws MalformedURLException, IOException, FileNotFoundException {
299304
File exeFinal = null;
300-
301-
302305

303306
File folder = new File(bindir + version + "/");
304307
File exe = new File(bindir + version + "/" + filename + "_TMP");
305308
exeFinal = new File(bindir + version + "/" + filename);
306-
if(exeFinal.exists()) {
307-
System.out.println("Skip Downloading "+ exeFinal+" exists already");
309+
if (exeFinal.exists()) {
310+
System.out.println("Skip Downloading " + exeFinal + " exists already");
308311
return exeFinal;
309312
}
310-
313+
311314
System.out.printf("Downloading %s %n", downloadURL);
312315

313316
if (downloadURL != null) {

0 commit comments

Comments
 (0)