better installer and portable mode

This commit is contained in:
olcxja 2026-09-25 21:15:17 +02:00
commit 53a02cc7da
6 changed files with 97 additions and 79 deletions

View file

@ -3,8 +3,6 @@
const path = require('path')
const fs = require('fs')
const APP_NAME = 'PLWL'
function findPng() {
const p = path.resolve(__dirname, '..', 'renderer', 'plwl.png')
try {
@ -15,44 +13,12 @@ function findPng() {
}
}
function writeIconThemeDirs(png) {
try {
const sizes = { '16x16': 16, '32x32': 32, '48x48': 48, '256x256': 256 }
const home = process.env.HOME
if (!home) return
const exe = path.join(require('./paths').APP_ROOT, 'plwl')
const execPath = fs.existsSync(exe)
? exe
: (process.env.PLWL_EXEC || 'plwl')
const base = path.join(home, '.local', 'share', 'icons')
for (const [dir, size] of Object.entries(sizes)) {
const themeDir = path.join(base, 'hicolor', dir, 'apps')
fs.mkdirSync(themeDir, { recursive: true })
fs.copyFileSync(png, path.join(themeDir, 'plwl.png'))
}
const desktopDir = path.join(home, '.local', 'share', 'applications')
fs.mkdirSync(desktopDir, { recursive: true })
const desktop = [
'[Desktop Entry]',
'Type=Application',
`Name=${APP_NAME}`,
'Comment=Portable Linux Wine Launcher',
`Exec=${execPath}`,
`Icon=plwl`,
'Terminal=false',
'Categories=Game;'
].join('\n')
fs.writeFileSync(path.join(desktopDir, 'plwl.desktop'), desktop)
} catch {}
}
function setAppIcon(app) {
const png = findPng()
if (!png) return
try {
app.setIcon(png)
} catch {}
writeIconThemeDirs(png)
}
module.exports = { setAppIcon }

View file

@ -3,7 +3,7 @@
const path = require('path')
const fs = require('fs')
// Packaged builds run from <portable root>/electron/resources/app.asar:
// Packaged builds run from <portable root>/olcxja.plwl/resources/app.asar:
// the portable layout (<root>/files) is two levels above the resources dir
// and files bundled with the release are unpacked next to the asar.
function computeRoots() {