-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathstudiomode.go
103 lines (87 loc) · 2.34 KB
/
studiomode.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package main
import (
"fmt"
"strconv"
studiomode "github.com/andreykaipov/goobs/api/requests/studio_mode"
"github.com/muesli/coral"
)
var (
studioModeCmd = &coral.Command{
Use: "studiomode",
Short: "manage studio mode",
Long: `The studiomode command manages the studio mode`,
RunE: nil,
}
disableStudioModeCmd = &coral.Command{
Use: "disable",
Short: "Disables the studio mode",
RunE: func(cmd *coral.Command, args []string) error {
return disableStudioMode()
},
}
enableStudioModeCmd = &coral.Command{
Use: "enable",
Short: "Enables the studio mode",
RunE: func(cmd *coral.Command, args []string) error {
return enableStudioMode()
},
}
studioModeStatusCmd = &coral.Command{
Use: "status",
Short: "Reports studio mode status",
RunE: func(cmd *coral.Command, args []string) error {
return studioModeStatus()
},
}
toggleStudioModeCmd = &coral.Command{
Use: "toggle",
Short: "Toggles the studio mode (enable/disable)",
RunE: func(cmd *coral.Command, args []string) error {
return toggleStudioMode()
},
}
transitionToProgramCmd = &coral.Command{
Use: "transition",
Short: "Transition to program",
RunE: func(cmd *coral.Command, args []string) error {
return transitionToProgram()
},
}
)
func disableStudioMode() error {
_, err := client.StudioMode.DisableStudioMode()
return err
}
func enableStudioMode() error {
_, err := client.StudioMode.EnableStudioMode()
return err
}
// Determine if the studio mode is currently enabled in OBS.
func IsStudioModeEnabled() (bool, error) {
r, err := client.StudioMode.GetStudioModeStatus()
return r.StudioMode, err
}
func studioModeStatus() error {
isStudioModeEnabled, err := IsStudioModeEnabled()
if err != nil {
return err
}
fmt.Printf("Studio Mode: %s\n", strconv.FormatBool(isStudioModeEnabled))
return nil
}
func toggleStudioMode() error {
_, err := client.StudioMode.ToggleStudioMode()
return err
}
func transitionToProgram() error {
_, err := client.StudioMode.TransitionToProgram(&studiomode.TransitionToProgramParams{})
return err
}
func init() {
studioModeCmd.AddCommand(disableStudioModeCmd)
studioModeCmd.AddCommand(enableStudioModeCmd)
studioModeCmd.AddCommand(studioModeStatusCmd)
studioModeCmd.AddCommand(toggleStudioModeCmd)
studioModeCmd.AddCommand(transitionToProgramCmd)
rootCmd.AddCommand(studioModeCmd)
}