mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-06-12 03:13:39 -07:00
Fix Windows mpv handoff and tray setup (#82)
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import path from 'node:path';
|
||||
import { loadRawConfigStrict } from './config/load';
|
||||
import { resolveConfig } from './config/resolve';
|
||||
import type { MpvLaunchMode, ResolvedConfig } from './types/config';
|
||||
import type { SubminerPluginRuntimeScriptOptConfig } from './shared/subminer-plugin-script-opts';
|
||||
|
||||
export interface ConfiguredWindowsMpvLaunch {
|
||||
executablePath: string;
|
||||
launchMode: MpvLaunchMode;
|
||||
pluginRuntimeConfig: SubminerPluginRuntimeScriptOptConfig;
|
||||
}
|
||||
|
||||
export function buildWindowsMpvPluginRuntimeConfig(
|
||||
config: Pick<ResolvedConfig, 'auto_start_overlay' | 'mpv' | 'texthooker'>,
|
||||
): SubminerPluginRuntimeScriptOptConfig {
|
||||
return {
|
||||
socketPath: config.mpv.socketPath,
|
||||
binaryPath: config.mpv.subminerBinaryPath,
|
||||
backend: config.mpv.backend,
|
||||
autoStart: config.mpv.autoStartSubMiner,
|
||||
autoStartVisibleOverlay: config.auto_start_overlay,
|
||||
autoStartPauseUntilReady: config.mpv.pauseUntilOverlayReady,
|
||||
texthookerEnabled: config.texthooker.launchAtStartup,
|
||||
aniskipEnabled: config.mpv.aniskipEnabled,
|
||||
aniskipButtonKey: config.mpv.aniskipButtonKey,
|
||||
};
|
||||
}
|
||||
|
||||
export function readConfiguredWindowsMpvLaunch(configDir: string): ConfiguredWindowsMpvLaunch {
|
||||
const loadResult = loadRawConfigStrict({
|
||||
configDir,
|
||||
configFileJsonc: path.join(configDir, 'config.jsonc'),
|
||||
configFileJson: path.join(configDir, 'config.json'),
|
||||
});
|
||||
const rawConfig = loadResult.ok ? loadResult.config : {};
|
||||
const { resolved } = resolveConfig(rawConfig);
|
||||
|
||||
return {
|
||||
executablePath: resolved.mpv.executablePath,
|
||||
launchMode: resolved.mpv.launchMode,
|
||||
pluginRuntimeConfig: buildWindowsMpvPluginRuntimeConfig(resolved),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user