mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-26 00:55:16 -07:00
feat(launcher): add mpv.profile config option for managed launches (#80)
This commit is contained in:
@@ -229,6 +229,29 @@ test('getDefaultSocketPath returns Windows named pipe default', () => {
|
||||
assert.equal(getDefaultSocketPath('win32'), '\\\\.\\pipe\\subminer-socket');
|
||||
});
|
||||
|
||||
test('parseLauncherMpvConfig reads configured mpv profile', () => {
|
||||
assert.deepEqual(
|
||||
parseLauncherMpvConfig({
|
||||
mpv: {
|
||||
profile: ' anime ',
|
||||
},
|
||||
}),
|
||||
{
|
||||
launchMode: undefined,
|
||||
socketPath: undefined,
|
||||
backend: undefined,
|
||||
autoStartSubMiner: undefined,
|
||||
pauseUntilOverlayReady: undefined,
|
||||
subminerBinaryPath: undefined,
|
||||
profile: 'anime',
|
||||
aniskipEnabled: undefined,
|
||||
aniskipButtonKey: undefined,
|
||||
},
|
||||
);
|
||||
|
||||
assert.equal(parseLauncherMpvConfig({ mpv: { profile: ' ' } }).profile, undefined);
|
||||
});
|
||||
|
||||
test('readExternalYomitanProfilePath detects configured external profile paths', () => {
|
||||
assert.equal(
|
||||
readExternalYomitanProfilePath({
|
||||
|
||||
@@ -45,6 +45,20 @@ test('createDefaultArgs normalizes configured language codes and env thread over
|
||||
}
|
||||
});
|
||||
|
||||
test('createDefaultArgs seeds mpv profile from launcher config', () => {
|
||||
const parsed = createDefaultArgs({}, { profile: 'anime' });
|
||||
|
||||
assert.equal(parsed.profile, 'anime');
|
||||
});
|
||||
|
||||
test('applyRootOptionsToArgs appends CLI mpv profile to configured profile', () => {
|
||||
const parsed = createDefaultArgs({}, { profile: 'anime' });
|
||||
|
||||
applyRootOptionsToArgs(parsed, { profile: 'hdr' }, undefined);
|
||||
|
||||
assert.equal(parsed.profile, 'anime,hdr');
|
||||
});
|
||||
|
||||
test('applyRootOptionsToArgs maps file, directory, and url targets', () => {
|
||||
withTempDir((dir) => {
|
||||
const filePath = path.join(dir, 'movie.mkv');
|
||||
|
||||
@@ -68,6 +68,12 @@ function parseBackend(value: string): Backend {
|
||||
fail(`Invalid backend: ${value} (must be auto, hyprland, sway, x11, macos, or windows)`);
|
||||
}
|
||||
|
||||
function appendMpvProfile(current: string, next: string): string {
|
||||
const trimmed = next.trim();
|
||||
if (!trimmed) return current;
|
||||
return current ? `${current},${trimmed}` : trimmed;
|
||||
}
|
||||
|
||||
function parseDictionaryTarget(value: string): string {
|
||||
const trimmed = value.trim();
|
||||
if (!trimmed) {
|
||||
@@ -121,7 +127,7 @@ export function createDefaultArgs(
|
||||
backend: mpvConfig.backend ?? 'auto',
|
||||
directory: '.',
|
||||
recursive: false,
|
||||
profile: '',
|
||||
profile: mpvConfig.profile ?? '',
|
||||
startOverlay: false,
|
||||
whisperBin: process.env.SUBMINER_WHISPER_BIN || launcherConfig.whisperBin || '',
|
||||
whisperModel: process.env.SUBMINER_WHISPER_MODEL || launcherConfig.whisperModel || '',
|
||||
@@ -215,7 +221,8 @@ export function applyRootOptionsToArgs(
|
||||
if (typeof options.backend === 'string') parsed.backend = parseBackend(options.backend);
|
||||
if (typeof options.directory === 'string') parsed.directory = options.directory;
|
||||
if (options.recursive === true) parsed.recursive = true;
|
||||
if (typeof options.profile === 'string') parsed.profile = options.profile;
|
||||
if (typeof options.profile === 'string')
|
||||
parsed.profile = appendMpvProfile(parsed.profile, options.profile);
|
||||
if (options.start === true) parsed.startOverlay = true;
|
||||
if (typeof options.logLevel === 'string') parsed.logLevel = parseLogLevel(options.logLevel);
|
||||
if (typeof options.passwordStore === 'string') parsed.passwordStore = options.passwordStore;
|
||||
|
||||
@@ -31,6 +31,7 @@ export function parseLauncherMpvConfig(root: Record<string, unknown>): LauncherM
|
||||
|
||||
return {
|
||||
launchMode: parseMpvLaunchMode(mpv.launchMode),
|
||||
profile: parseNonEmptyString(mpv.profile),
|
||||
socketPath: parseNonEmptyString(mpv.socketPath),
|
||||
backend: parseBackend(mpv.backend),
|
||||
autoStartSubMiner:
|
||||
|
||||
@@ -268,6 +268,18 @@ test('buildConfiguredMpvDefaultArgs appends maximized launch mode to configured
|
||||
});
|
||||
});
|
||||
|
||||
test('buildConfiguredMpvDefaultArgs passes configured mpv profile before SubMiner defaults', () => {
|
||||
withPlatform('linux', () => {
|
||||
assert.deepEqual(
|
||||
buildConfiguredMpvDefaultArgs(makeArgs({ profile: 'anime,hdr' }), {
|
||||
DISPLAY: ':1',
|
||||
XDG_SESSION_TYPE: 'x11',
|
||||
}).slice(0, 2),
|
||||
['--profile=anime,hdr', '--sub-auto=fuzzy'],
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('buildConfiguredMpvDefaultArgs disables macOS menu shortcuts so SubMiner bindings reach mpv', () => {
|
||||
withPlatform('darwin', () => {
|
||||
assert.equal(
|
||||
|
||||
@@ -30,6 +30,12 @@ test('parseArgs captures mpv args string', () => {
|
||||
assert.equal(parsed.mpvArgs, '--pause=yes --title="movie night"');
|
||||
});
|
||||
|
||||
test('parseArgs appends CLI mpv profile to configured mpv profile', () => {
|
||||
const parsed = parseArgs(['--profile', 'hdr'], 'subminer', {}, { profile: 'anime' });
|
||||
|
||||
assert.equal(parsed.profile, 'anime,hdr');
|
||||
});
|
||||
|
||||
test('parseArgs maps root settings window option', () => {
|
||||
const parsed = parseArgs(['--settings'], 'subminer', {});
|
||||
|
||||
|
||||
@@ -175,6 +175,7 @@ export interface LauncherJellyfinConfig {
|
||||
|
||||
export interface LauncherMpvConfig {
|
||||
launchMode?: MpvLaunchMode;
|
||||
profile?: string;
|
||||
socketPath?: string;
|
||||
backend?: MpvBackend;
|
||||
autoStartSubMiner?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user