Skip to content

Commit

Permalink
Add the "sceneitem visible" command
Browse files Browse the repository at this point in the history
```
obs-cli sceneitem visible <scene> <item>
```

Will display "name-of-item: true" (or false)
  • Loading branch information
twidi authored and muesli committed Jan 28, 2022
1 parent 7308a34 commit c15b1ea
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ obs-cli sceneitem hide <scene> <item>
obs-cli sceneitem toggle <scene> <item>
```

View the visibility of a scene-item:

```
obs-cli sceneitem visible <scene> <item>
```

Center a scene-item horizontally:

```
Expand Down
29 changes: 29 additions & 0 deletions sceneitems.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ var (
},
}

getSceneItemVisibilityCmd = &cobra.Command{
Use: "visible",
Short: "Show visibility status of a scene-item",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) < 2 {
return errors.New("visible requires a scene and scene-item")
}
return getSceneItemVisibility(args[0], args[1:]...)
},
}

centerSceneItemCmd = &cobra.Command{
Use: "center",
Short: "Horizontally centers a scene-item",
Expand Down Expand Up @@ -144,6 +155,23 @@ func toggleSceneItem(scene string, items ...string) error {
return nil
}

func getSceneItemVisibility(scene string, items ...string) error {
for _, item := range items {
p := sceneitems.GetSceneItemPropertiesParams{
Item: &typedefs.Item{Name: item},
SceneName: scene,
}
resp, err := client.SceneItems.GetSceneItemProperties(&p)
if err != nil {
return err
}

fmt.Printf("%s: %t\n", resp.Name, *resp.Visible)
}

return nil
}

func centerSceneItem(scene string, items ...string) error {
for _, item := range items {
p := sceneitems.GetSceneItemPropertiesParams{
Expand Down Expand Up @@ -188,6 +216,7 @@ func init() {
sceneItemCmd.AddCommand(toggleSceneItemCmd)
sceneItemCmd.AddCommand(showSceneItemCmd)
sceneItemCmd.AddCommand(hideSceneItemCmd)
sceneItemCmd.AddCommand(getSceneItemVisibilityCmd)
sceneItemCmd.AddCommand(listSceneItemsCmd)
rootCmd.AddCommand(sceneItemCmd)
}

0 comments on commit c15b1ea

Please sign in to comment.