cleanup comments, update translations, bump to 0.4.1
This commit is contained in:
parent
9edcc9841b
commit
7d8ab87eee
28 changed files with 412 additions and 1114 deletions
|
|
@ -1,9 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
// .desktop shortcut generation. A shortcut launches the launcher itself with
|
||||
// `--launch <id>`: the main process either starts the game in the running
|
||||
// instance or boots headless (no window, tray only), starts the game and lets
|
||||
// playtime tracking continue normally.
|
||||
// .desktop shortcut generation: a shortcut runs the launcher with
|
||||
// `--launch <id>` (headless boot when nothing is running yet).
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
|
@ -11,8 +9,7 @@ const { DIRS, resolvePortablePath, launcherIconDiskPath } = require('./paths')
|
|||
|
||||
const DATA_DIR = process.env.PLWL_BUILD_DIR ? path.join(process.env.PLWL_BUILD_DIR, 'files', 'data') : DIRS.DATA
|
||||
|
||||
// Where user-visible shortcuts live (XDG). Override with PLWL_SHORTCUTS_DIR
|
||||
// so tests (and portable exotic setups) can redirect it.
|
||||
// XDG shortcuts dir; PLWL_SHORTCUTS_DIR overrides it (tests).
|
||||
function desktopDirs() {
|
||||
const home = process.env.HOME || '/'
|
||||
const dataHome = process.env.XDG_DATA_HOME || path.join(home, '.local', 'share')
|
||||
|
|
@ -22,8 +19,7 @@ function desktopDirs() {
|
|||
}
|
||||
}
|
||||
|
||||
// Launcher executable as the shortcut will see it, as an argv list: the
|
||||
// packaged olcxja.plwl/olcxja.plwl binary, or `electron <project>` in dev.
|
||||
// The launcher executable as an argv list (packaged binary or electron dev).
|
||||
function launcherArgv() {
|
||||
if (process.env.PLWL_LAUNCHER_CMD) return process.env.PLWL_LAUNCHER_CMD.split(' ').filter(Boolean)
|
||||
const m = __dirname.match(/^(.*)[/\\]app\.asar([/\\]|$)/)
|
||||
|
|
@ -36,19 +32,13 @@ function launcherArgv() {
|
|||
return ['electron', path.resolve(__dirname, '..')]
|
||||
}
|
||||
|
||||
// Desktop Entry Exec field escaping (per the spec): % must be doubled,
|
||||
// quotes and backslashes escaped, and tokens containing spaces wrapped in
|
||||
// double quotes.
|
||||
// Desktop Entry Exec escaping per the spec (% doubled, quotes, spaces).
|
||||
function execToken(token) {
|
||||
const escaped = token.replace(/%/g, '%%').replace(/\\/g, '\\\\').replace(/"/g, '\\"')
|
||||
return /[ $"'\\]/.test(token) ? `"${escaped}"` : escaped
|
||||
}
|
||||
|
||||
// The `%f` file field is appended AFTER escaping (a literal % would have been
|
||||
// doubled into a literal). It makes the shortcut a file handler: the file
|
||||
// manager substitutes the opened file there - and removes the field when the
|
||||
// shortcut is launched from the menu - so "Open with" on the shortcut runs the
|
||||
// app with that file, like it does on Windows.
|
||||
// %f appended after escaping makes the shortcut a file handler.
|
||||
function execLine(extraArgs) {
|
||||
const tokens = [...launcherArgv(), ...String(extraArgs).split(' ').filter(Boolean)]
|
||||
return [...tokens.map(execToken), '%f'].join(' ')
|
||||
|
|
@ -68,8 +58,7 @@ function buildDesktopEntry(game) {
|
|||
if (found) icon = path.join(iconDir, found)
|
||||
} catch {}
|
||||
if (!icon) {
|
||||
// fall back to the launcher icon so the shortcut is never naked (the
|
||||
// on-disk copy: the desktop environment cannot read inside app.asar)
|
||||
// on-disk launcher icon fallback (Icon= cannot read the asar)
|
||||
icon = launcherIconDiskPath() || ''
|
||||
}
|
||||
const lines = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue