update README.md and add linux-mpv-handler scripts
This commit is contained in:
@@ -9,6 +9,9 @@ import { fileURLToPath } from 'node:url'
|
||||
const scriptPath = fileURLToPath(import.meta.url)
|
||||
const scriptDir = path.dirname(scriptPath)
|
||||
const templateConfigPath = path.join(scriptDir, 'config.toml')
|
||||
const bundledLinuxHandlerPath = path.join(scriptDir, 'linux-mpv-handler.py')
|
||||
const bundledLinuxDesktopPath = path.join(scriptDir, 'linux-mpv-handler.desktop')
|
||||
const bundledLinuxDebugDesktopPath = path.join(scriptDir, 'linux-mpv-handler-debug.desktop')
|
||||
const UPSTREAM_MPV_HANDLER_REPO = 'https://github.com/akiirui/mpv-handler.git'
|
||||
const UPSTREAM_MPV_HANDLER_REF = 'v0.4.2'
|
||||
|
||||
@@ -216,6 +219,27 @@ function prepareLinuxSourceBuildRoot(options) {
|
||||
return stageDir
|
||||
}
|
||||
|
||||
function prepareBundledLinuxHandlerRoot(options) {
|
||||
const cacheDir = getLinuxCacheDir()
|
||||
const stageDir = path.join(cacheDir, 'linux-bundled-handler')
|
||||
|
||||
if (options.dryRun) {
|
||||
console.log(`Dry run: would stage bundled Linux handler into ${stageDir}`)
|
||||
return stageDir
|
||||
}
|
||||
|
||||
mkdirSync(cacheDir, { recursive: true })
|
||||
mkdirSync(stageDir, { recursive: true })
|
||||
|
||||
copyFileSync(bundledLinuxHandlerPath, path.join(stageDir, 'mpv-handler'))
|
||||
copyFileSync(bundledLinuxDesktopPath, path.join(stageDir, 'mpv-handler.desktop'))
|
||||
copyFileSync(bundledLinuxDebugDesktopPath, path.join(stageDir, 'mpv-handler-debug.desktop'))
|
||||
copyFileSync(templateConfigPath, path.join(stageDir, 'config.toml'))
|
||||
chmodSync(path.join(stageDir, 'mpv-handler'), 0o755)
|
||||
|
||||
return stageDir
|
||||
}
|
||||
|
||||
function resolveRoot(options) {
|
||||
const resolvedRoot = findRoot(options)
|
||||
if (resolvedRoot) return resolvedRoot
|
||||
@@ -225,13 +249,21 @@ function resolveRoot(options) {
|
||||
}
|
||||
|
||||
if (process.platform === 'linux') {
|
||||
if (process.arch !== 'x64' && !options.skipSourceBuild) {
|
||||
return prepareLinuxSourceBuildRoot(options)
|
||||
if (process.arch !== 'x64') {
|
||||
if (!options.skipSourceBuild) {
|
||||
const gitPath = resolveOnPath(['git'])
|
||||
const cargoPath = resolveOnPath(['cargo'])
|
||||
if (gitPath && cargoPath) {
|
||||
return prepareLinuxSourceBuildRoot(options)
|
||||
}
|
||||
}
|
||||
|
||||
return prepareBundledLinuxHandlerRoot(options)
|
||||
}
|
||||
|
||||
const archHint = process.arch === 'x64'
|
||||
? 'Download and extract the upstream archive, then pass --root /path/to/extracted/mpv-handler-linux-amd64.'
|
||||
: `The upstream project only publishes an official linux-amd64 archive. Install git and cargo to allow automatic source builds, or build/obtain a compatible mpv-handler binary and pass --root /path/to/extracted/mpv-handler.`
|
||||
: `The upstream project only publishes an official linux-amd64 archive. Install git and cargo to allow automatic source builds, use the bundled fallback handler, or build/obtain a compatible mpv-handler binary and pass --root /path/to/extracted/mpv-handler.`
|
||||
fail(`Could not find a Linux mpv-handler release. ${archHint}`)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user