mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-15 18:02:58 +08:00
fix: icons not displaying on some Linux systems
This commit is contained in:
@@ -384,6 +384,7 @@ tasks.register<Exec>("jpackage") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (os.isLinux) {
|
if (os.isLinux) {
|
||||||
|
options.add("--add-opens=java.desktop/sun.awt.X11=ALL-UNNAMED")
|
||||||
if (isDeb) {
|
if (isDeb) {
|
||||||
options.add("-Djpackage.app-layout=deb")
|
options.add("-Djpackage.app-layout=deb")
|
||||||
}
|
}
|
||||||
@@ -681,17 +682,24 @@ fun packOnLinux(distributionDir: Directory, finalFilenameWithoutExtension: Strin
|
|||||||
exec { commandLine("chmod", "+x", appimagetool.absolutePath) }
|
exec { commandLine("chmod", "+x", appimagetool.absolutePath) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Desktop file
|
// Desktop file
|
||||||
val termoraName = project.name.uppercaseFirstChar()
|
val termoraName = project.name.uppercaseFirstChar()
|
||||||
|
|
||||||
|
// copy icon
|
||||||
|
FileUtils.copyFile(
|
||||||
|
File("${projectDir.absolutePath}/src/main/resources/icons/termora_256x256.png"),
|
||||||
|
distributionDir.file(termoraName + File.separator + termoraName + ".png").asFile
|
||||||
|
)
|
||||||
|
|
||||||
val desktopFile = distributionDir.file(termoraName + File.separator + termoraName + ".desktop").asFile
|
val desktopFile = distributionDir.file(termoraName + File.separator + termoraName + ".desktop").asFile
|
||||||
desktopFile.writeText(
|
desktopFile.writeText(
|
||||||
"""[Desktop Entry]
|
"""[Desktop Entry]
|
||||||
Type=Application
|
Type=Application
|
||||||
Name=${termoraName}
|
Name=${termoraName}
|
||||||
Comment=Terminal emulator and SSH client
|
Comment=Terminal emulator and SSH client
|
||||||
Icon=/lib/${termoraName}
|
Icon=${termoraName}
|
||||||
Categories=Development;
|
Categories=Development;
|
||||||
|
StartupWMClass=${termoraName}
|
||||||
Terminal=false
|
Terminal=false
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import org.apache.commons.lang3.SystemUtils
|
|||||||
import org.apache.commons.lang3.math.NumberUtils
|
import org.apache.commons.lang3.math.NumberUtils
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.tinylog.configuration.Configuration
|
import org.tinylog.configuration.Configuration
|
||||||
|
import java.awt.Toolkit
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
import kotlin.system.measureTimeMillis
|
import kotlin.system.measureTimeMillis
|
||||||
@@ -35,10 +36,20 @@ class ApplicationInitializr {
|
|||||||
// 检查是否单例
|
// 检查是否单例
|
||||||
checkSingleton()
|
checkSingleton()
|
||||||
|
|
||||||
if (SystemUtils.IS_OS_MAC_OSX) {
|
if (SystemInfo.isMacOS) {
|
||||||
System.setProperty("apple.awt.application.name", Application.getName())
|
System.setProperty("apple.awt.application.name", Application.getName())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SystemInfo.isLinux) {
|
||||||
|
// https://stackoverflow.com/questions/10593075
|
||||||
|
runCatching {
|
||||||
|
val toolkit = Toolkit.getDefaultToolkit()
|
||||||
|
val awtAppClassNameField = toolkit.javaClass.getDeclaredField("awtAppClassName")
|
||||||
|
awtAppClassNameField.setAccessible(true)
|
||||||
|
awtAppClassNameField.set(toolkit, Application.getName())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 启动
|
// 启动
|
||||||
val runtime = measureTimeMillis { ApplicationRunner().run() }
|
val runtime = measureTimeMillis { ApplicationRunner().run() }
|
||||||
val log = LoggerFactory.getLogger(javaClass)
|
val log = LoggerFactory.getLogger(javaClass)
|
||||||
|
|||||||
BIN
src/main/resources/icons/termora_256x256.png
Normal file
BIN
src/main/resources/icons/termora_256x256.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
Reference in New Issue
Block a user