mirror of
https://github.com/onyx-and-iris/gobs-cli.git
synced 2025-06-09 21:20:34 +01:00
add projector commands
add ProjectorCmd section to README
This commit is contained in:
parent
360d45aa47
commit
af962a26cc
27
README.md
27
README.md
@ -524,6 +524,33 @@ gobs-cli toggle 'Mic/Aux' 'Gain'
|
|||||||
gobs-cli status 'Mic/Aux' 'Gain'
|
gobs-cli status 'Mic/Aux' 'Gain'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### ProjectorCmd
|
||||||
|
|
||||||
|
- list-monitors: List available monitors.
|
||||||
|
|
||||||
|
```console
|
||||||
|
gobs-cli projector list-monitors
|
||||||
|
```
|
||||||
|
|
||||||
|
- open: Open a fullscreen projector for a source on a specific monitor.
|
||||||
|
- flags:
|
||||||
|
|
||||||
|
*optional*
|
||||||
|
- --monitor-index: Index of the monitor to open the projector on.
|
||||||
|
- defaults to 0
|
||||||
|
|
||||||
|
*optional*
|
||||||
|
- args: <source_name>
|
||||||
|
- defaults to current scene
|
||||||
|
|
||||||
|
```console
|
||||||
|
gobs-cli project open
|
||||||
|
|
||||||
|
gobs-cli projector open --monitor-index=1 "test_scene"
|
||||||
|
|
||||||
|
gobs-cli projector open --monitor-index=1 "test_group"
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
[userconfigdir]: https://pkg.go.dev/os#UserConfigDir
|
[userconfigdir]: https://pkg.go.dev/os#UserConfigDir
|
||||||
[obs-keyids]: https://github.com/obsproject/obs-studio/blob/master/libobs/obs-hotkeys.h
|
[obs-keyids]: https://github.com/obsproject/obs-studio/blob/master/libobs/obs-hotkeys.h
|
1
main.go
1
main.go
@ -45,6 +45,7 @@ type CLI struct {
|
|||||||
Virtualcam VirtualCamCmd `help:"Manage virtual camera." cmd:"" aliases:"vc"`
|
Virtualcam VirtualCamCmd `help:"Manage virtual camera." cmd:"" aliases:"vc"`
|
||||||
Hotkey HotkeyCmd `help:"Manage hotkeys." cmd:"" aliases:"hk"`
|
Hotkey HotkeyCmd `help:"Manage hotkeys." cmd:"" aliases:"hk"`
|
||||||
Filter FilterCmd `help:"Manage filters." cmd:"" aliases:"f"`
|
Filter FilterCmd `help:"Manage filters." cmd:"" aliases:"f"`
|
||||||
|
Projector ProjectorCmd `help:"Manage projectors." cmd:"" aliases:"prj"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type context struct {
|
type context struct {
|
||||||
|
66
projector.go
Normal file
66
projector.go
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/andreykaipov/goobs/api/requests/ui"
|
||||||
|
"github.com/aquasecurity/table"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProjectorCmd provides a command to manage projectors in OBS.
|
||||||
|
type ProjectorCmd struct {
|
||||||
|
ListMonitors ProjectorListMonitorsCmd `cmd:"" help:"List available monitors." aliases:"ls-m"`
|
||||||
|
Open ProjectorOpenCmd `cmd:"" help:"Open a fullscreen projector for a source on a specific monitor." aliases:"o"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProjectorListMonitorsCmd provides a command to list all monitors available for projectors.
|
||||||
|
type ProjectorListMonitorsCmd struct{} // size = 0x0
|
||||||
|
|
||||||
|
// Run executes the command to list all monitors available for projectors.
|
||||||
|
func (cmd *ProjectorListMonitorsCmd) Run(ctx *context) error {
|
||||||
|
monitors, err := ctx.Client.Ui.GetMonitorList()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(monitors.Monitors) == 0 {
|
||||||
|
ctx.Out.Write([]byte("No monitors found for projectors.\n"))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
t := table.New(ctx.Out)
|
||||||
|
t.SetPadding(3)
|
||||||
|
t.SetAlignment(table.AlignCenter, table.AlignLeft)
|
||||||
|
t.SetHeaders("Monitor ID", "Monitor Name")
|
||||||
|
|
||||||
|
for _, monitor := range monitors.Monitors {
|
||||||
|
t.AddRow(fmt.Sprintf("%d", monitor.MonitorIndex), monitor.MonitorName)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Render()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProjectorOpenCmd provides a command to open a fullscreen projector for a specific source.
|
||||||
|
type ProjectorOpenCmd struct {
|
||||||
|
MonitorIndex int `flag:"" help:"Index of the monitor to open the projector on." default:"0"`
|
||||||
|
SourceName string ` help:"Name of the source to project." default:"" arg:""`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run executes the command to show details of a specific projector.
|
||||||
|
func (cmd *ProjectorOpenCmd) Run(ctx *context) error {
|
||||||
|
if cmd.SourceName == "" {
|
||||||
|
currentScene, err := ctx.Client.Scenes.GetCurrentProgramScene()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to get current program scene: %w", err)
|
||||||
|
}
|
||||||
|
cmd.SourceName = currentScene.SceneName
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.Client.Ui.OpenSourceProjector(ui.NewOpenSourceProjectorParams().
|
||||||
|
WithSourceName(cmd.SourceName).
|
||||||
|
WithMonitorIndex(cmd.MonitorIndex))
|
||||||
|
|
||||||
|
fmt.Fprintf(ctx.Out, "Opened projector for source '%s' on monitor index %d.\n", cmd.SourceName, cmd.MonitorIndex)
|
||||||
|
return nil
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user