add projector subtyper

This commit is contained in:
onyx-and-iris 2025-05-26 20:54:22 +01:00
parent b5364bfedc
commit 2739fa28f0
2 changed files with 60 additions and 0 deletions

View File

@ -12,6 +12,7 @@ from . import (
hotkey,
input,
profile,
projector,
record,
replaybuffer,
scene,
@ -30,6 +31,7 @@ for module in (
group,
hotkey,
input,
projector,
profile,
record,
replaybuffer,

58
obsws_cli/projector.py Normal file
View File

@ -0,0 +1,58 @@
"""module containing commands for manipulating projectors in OBS."""
from typing import Annotated
import typer
from rich.console import Console
from rich.table import Table
from .alias import AliasGroup
app = typer.Typer(cls=AliasGroup)
out_console = Console()
err_console = Console(stderr=True)
@app.callback()
def main():
"""Control projectors in OBS."""
@app.command('list-monitors | ls-m')
def list_monitors(ctx: typer.Context):
"""List available monitors."""
resp = ctx.obj.get_monitor_list()
if not resp.monitors:
out_console.print('No monitors found.')
return
monitors = sorted(
((m['monitorIndex'], m['monitorName']) for m in resp.monitors),
key=lambda m: m[0],
)
table = Table(title='Available Monitors', padding=(0, 2))
table.add_column('Index', justify='right', style='cyan')
table.add_column('Name', style='cyan')
for index, monitor in monitors:
table.add_row(str(index), monitor)
out_console.print(table)
@app.command('open | o')
def open(
ctx: typer.Context,
source_name: str,
monitor_index: Annotated[
int,
typer.Option(help='Index of the monitor to open the projector on.'),
] = 0,
):
"""Open a fullscreen projector for a source on a specific monitor."""
ctx.obj.open_source_projector(
source_name=source_name,
monitor_index=monitor_index,
)