'use strict' const path = require('path') const fs = require('fs') const APP_NAME = 'PLWL' function findPng() { const p = path.resolve(__dirname, '..', 'renderer', 'plwl.png') try { fs.accessSync(p) return p } catch { return null } } 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 }