-
Notifications
You must be signed in to change notification settings - Fork 38
/
sources.go
87 lines (74 loc) · 1.61 KB
/
sources.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
package main
import (
"errors"
"fmt"
"github.com/andreykaipov/goobs/api/requests/sources"
"github.com/muesli/coral"
)
var (
sourceCmd = &coral.Command{
Use: "source",
Short: "manage sources",
Long: `The source command manages sources`,
RunE: nil,
}
listSourcesCmd = &coral.Command{
Use: "list",
Short: "Lists all sources",
RunE: func(cmd *coral.Command, args []string) error {
return listSources()
},
}
toggleMuteCmd = &coral.Command{
Use: "toggle-mute",
Short: "Toggles mute",
RunE: func(cmd *coral.Command, args []string) error {
if len(args) < 1 {
return errors.New("toggle-mute requires a source name as argument")
}
return toggleMute(args[0])
},
}
)
func listSources() error {
/*
{
req := obsws.NewGetSourcesListRequest()
resp, err := req.SendReceive(client)
if err != nil {
return err
}
fmt.Println("Sources\n=======\n")
for _, v := range resp.Sources {
spew.Dump(v)
}
fmt.Println()
}
*/
{
resp, err := client.Sources.GetSpecialSources()
if err != nil {
return err
}
fmt.Println("Special Sources")
fmt.Println("===============")
fmt.Printf("Desktop1: %s\n", resp.Desktop1)
fmt.Printf("Desktop2: %s\n", resp.Desktop2)
fmt.Printf("Mic1: %s\n", resp.Mic1)
fmt.Printf("Mic2: %s\n", resp.Mic2)
fmt.Printf("Mic3: %s\n", resp.Mic3)
}
return nil
}
func toggleMute(source string) error {
p := sources.ToggleMuteParams{
Source: source,
}
_, err := client.Sources.ToggleMute(&p)
return err
}
func init() {
sourceCmd.AddCommand(listSourcesCmd)
sourceCmd.AddCommand(toggleMuteCmd)
rootCmd.AddCommand(sourceCmd)
}