add support for directly launching windows exes from file exporer using .desktop shortcut

This commit is contained in:
olcxja 2026-09-30 17:32:30 +02:00
commit 5e217472aa
15 changed files with 440 additions and 28 deletions

View file

@ -10,6 +10,15 @@ ipcRenderer.on('import:progress', (e, data) => {
if (importProgressCb) importProgressCb(data)
})
// "Open with PLWL": single-slot callback for files handed over via --open
// (Exec %f) - the renderer shows the wine/prefix picker popup for it.
let openWithCb = null
ipcRenderer.on('openwith:file', (e, openPath) => {
if (openWithCb) openWithCb(openPath)
})
const fs = require('fs')
const path = require('path')
contextBridge.exposeInMainWorld('plwl', {
FILES_DIR: DIRS.FILES,
i18nList: () => ipcRenderer.invoke('i18n:list'),
@ -26,6 +35,20 @@ contextBridge.exposeInMainWorld('plwl', {
prefixesCreate: name => ipcRenderer.invoke('prefixes:create', name),
prefixesDelete: name => ipcRenderer.invoke('prefixes:delete', name),
prefixesSetDefault: name => ipcRenderer.invoke('prefixes:setDefault', name),
openwithTake: () => ipcRenderer.invoke('openwith:take'),
openwithRun: payload => ipcRenderer.invoke('openwith:run', payload),
openwithTexts: lang => ipcRenderer.invoke('openwith:texts', lang),
onOpenWith: cb => {
openWithCb = cb
},
basename: p => (p ? path.basename(p) : ''),
fileExists: p => {
try {
return !!p && fs.existsSync(p)
} catch {
return false
}
},
gamesList: () => ipcRenderer.invoke('games:list'),
gamesGet: id => ipcRenderer.invoke('games:get', id),
gamesUpdate: (id, patch) => ipcRenderer.invoke('games:update', id, patch),