convert studiomode commands

This commit is contained in:
onyx-and-iris 2025-07-24 04:05:01 +01:00
parent bb7a468dd5
commit eb939b735c
2 changed files with 31 additions and 21 deletions

View File

@ -36,6 +36,7 @@ for sub_app in (
'sceneitem', 'sceneitem',
'screenshot', 'screenshot',
'stream', 'stream',
'studiomode',
): ):
module = importlib.import_module(f'.{sub_app}', package=__package__) module = importlib.import_module(f'.{sub_app}', package=__package__)
app.command(module.app) app.command(module.app)

View File

@ -1,48 +1,57 @@
"""module containing commands for manipulating studio mode in OBS.""" """module containing commands for manipulating studio mode in OBS."""
import typer from typing import Annotated
from cyclopts import App, Parameter
from . import console from . import console
from .alias import SubTyperAliasGroup from .context import Context
app = typer.Typer(cls=SubTyperAliasGroup) app = App(name='studiomode', help='Commands for controlling studio mode in OBS.')
@app.callback() @app.command(name=['enable', 'on'])
def main(): def enable(
"""Control studio mode in OBS.""" *,
ctx: Annotated[Context, Parameter(parse=False)],
):
@app.command('enable | on')
def enable(ctx: typer.Context):
"""Enable studio mode.""" """Enable studio mode."""
ctx.obj['obsws'].set_studio_mode_enabled(True) ctx.obj['obsws'].set_studio_mode_enabled(True)
console.out.print('Studio mode has been enabled.') console.out.print('Studio mode has been enabled.')
@app.command('disable | off') @app.command(name=['disable', 'off'])
def disable(ctx: typer.Context): def disable(
*,
ctx: Annotated[Context, Parameter(parse=False)],
):
"""Disable studio mode.""" """Disable studio mode."""
ctx.obj['obsws'].set_studio_mode_enabled(False) ctx.client.set_studio_mode_enabled(False)
console.out.print('Studio mode has been disabled.') console.out.print('Studio mode has been disabled.')
@app.command('toggle | tg') @app.command(name=['toggle', 'tg'])
def toggle(ctx: typer.Context): def toggle(
*,
ctx: Annotated[Context, Parameter(parse=False)],
):
"""Toggle studio mode.""" """Toggle studio mode."""
resp = ctx.obj['obsws'].get_studio_mode_enabled() resp = ctx.client.get_studio_mode_enabled()
if resp.studio_mode_enabled: if resp.studio_mode_enabled:
ctx.obj['obsws'].set_studio_mode_enabled(False) ctx.client.set_studio_mode_enabled(False)
console.out.print('Studio mode is now disabled.') console.out.print('Studio mode is now disabled.')
else: else:
ctx.obj['obsws'].set_studio_mode_enabled(True) ctx.client.set_studio_mode_enabled(True)
console.out.print('Studio mode is now enabled.') console.out.print('Studio mode is now enabled.')
@app.command('status | ss') @app.command(name=['status', 'ss'])
def status(ctx: typer.Context): def status(
*,
ctx: Annotated[Context, Parameter(parse=False)],
):
"""Get the status of studio mode.""" """Get the status of studio mode."""
resp = ctx.obj['obsws'].get_studio_mode_enabled() resp = ctx.client.get_studio_mode_enabled()
if resp.studio_mode_enabled: if resp.studio_mode_enabled:
console.out.print('Studio mode is enabled.') console.out.print('Studio mode is enabled.')
else: else: