mirror of
https://github.com/onyx-and-iris/gobs-cli.git
synced 2025-08-07 20:21:48 +00:00
Compare commits
4 Commits
02541f9915
...
da010d67a0
Author | SHA1 | Date | |
---|---|---|---|
da010d67a0 | |||
0c695298fd | |||
2f77fa1c54 | |||
eafc3312a5 |
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
# [0.5.0] - 2025-05-22
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- hotkey commands, see [Hotkey](https://github.com/onyx-and-iris/gobs-cli?tab=readme-ov-file#hotkeycmd)
|
||||||
|
|
||||||
# [0.4.2] - 2025-05-08
|
# [0.4.2] - 2025-05-08
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@ -31,4 +37,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Initial release.
|
- Initial release.
|
||||||
|
37
README.md
37
README.md
@ -443,4 +443,39 @@ gobs-cli virtualcam toggle
|
|||||||
gobs-cli virtualcam status
|
gobs-cli virtualcam status
|
||||||
```
|
```
|
||||||
|
|
||||||
[userconfigdir]: https://pkg.go.dev/os#UserConfigDir
|
### HotkeyCmd
|
||||||
|
|
||||||
|
- list: List all hotkeys.
|
||||||
|
|
||||||
|
```console
|
||||||
|
gobs-cli hotkey list
|
||||||
|
```
|
||||||
|
|
||||||
|
- trigger: Trigger a hotkey by name.
|
||||||
|
|
||||||
|
```console
|
||||||
|
gobs-cli hotkey trigger OBSBasic.StartStreaming
|
||||||
|
|
||||||
|
gobs-cli hotkey trigger OBSBasic.StopStreaming
|
||||||
|
```
|
||||||
|
|
||||||
|
- trigger-sequence: Trigger a hotkey by sequence.
|
||||||
|
- flags:
|
||||||
|
|
||||||
|
*optional*
|
||||||
|
- --shift: Press shift.
|
||||||
|
- --ctrl: Press control.
|
||||||
|
- --alt: Press alt.
|
||||||
|
- --cmd: Press command (mac).
|
||||||
|
|
||||||
|
- args: keyID
|
||||||
|
- Check [obs-hotkeys.h][obs-keyids] for a full list of OBS key ids.
|
||||||
|
|
||||||
|
```console
|
||||||
|
gobs-cli hotkey trigger-sequence OBS_KEY_F1 --ctrl
|
||||||
|
|
||||||
|
gobs-cli hotkey trigger-sequence OBS_KEY_F1 --shift --ctrl
|
||||||
|
```
|
||||||
|
|
||||||
|
[userconfigdir]: https://pkg.go.dev/os#UserConfigDir
|
||||||
|
[obs-keyids]: https://github.com/obsproject/obs-studio/blob/master/libobs/obs-hotkeys.h
|
74
hotkey.go
Normal file
74
hotkey.go
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/andreykaipov/goobs/api/requests/general"
|
||||||
|
"github.com/andreykaipov/goobs/api/typedefs"
|
||||||
|
)
|
||||||
|
|
||||||
|
// HotkeyCmd provides commands to manage hotkeys in OBS Studio.
|
||||||
|
type HotkeyCmd struct {
|
||||||
|
List HotkeyListCmd `cmd:"" help:"List all hotkeys." aliases:"ls"`
|
||||||
|
Trigger HotkeyTriggerCmd `cmd:"" help:"Trigger a hotkey by name." aliases:"tr"`
|
||||||
|
TriggerSequence HotkeyTriggerSequenceCmd `cmd:"" help:"Trigger a hotkey by sequence." aliases:"trs"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// HotkeyListCmd provides a command to list all hotkeys.
|
||||||
|
type HotkeyListCmd struct{} // size = 0x0
|
||||||
|
|
||||||
|
// Run executes the command to list all hotkeys.
|
||||||
|
func (cmd *HotkeyListCmd) Run(ctx *context) error {
|
||||||
|
resp, err := ctx.Client.General.GetHotkeyList()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, hotkey := range resp.Hotkeys {
|
||||||
|
fmt.Fprintln(ctx.Out, hotkey)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// HotkeyTriggerCmd provides a command to trigger a hotkey.
|
||||||
|
type HotkeyTriggerCmd struct {
|
||||||
|
Hotkey string `help:"Hotkey name to trigger." arg:""`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run executes the command to trigger a hotkey.
|
||||||
|
func (cmd *HotkeyTriggerCmd) Run(ctx *context) error {
|
||||||
|
_, err := ctx.Client.General.TriggerHotkeyByName(
|
||||||
|
general.NewTriggerHotkeyByNameParams().WithHotkeyName(cmd.Hotkey),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// HotkeyTriggerSequenceCmd provides a command to trigger a hotkey sequence.
|
||||||
|
type HotkeyTriggerSequenceCmd struct {
|
||||||
|
Shift bool `flag:"" help:"Shift modifier."`
|
||||||
|
Ctrl bool `flag:"" help:"Control modifier."`
|
||||||
|
Alt bool `flag:"" help:"Alt modifier."`
|
||||||
|
Cmd bool `flag:"" help:"Command modifier."`
|
||||||
|
KeyID string ` help:"Key ID to trigger." arg:""`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run executes the command to trigger a hotkey sequence.
|
||||||
|
func (cmd *HotkeyTriggerSequenceCmd) Run(ctx *context) error {
|
||||||
|
_, err := ctx.Client.General.TriggerHotkeyByKeySequence(
|
||||||
|
general.NewTriggerHotkeyByKeySequenceParams().
|
||||||
|
WithKeyId(cmd.KeyID).
|
||||||
|
WithKeyModifiers(&typedefs.KeyModifiers{
|
||||||
|
Shift: cmd.Shift,
|
||||||
|
Control: cmd.Ctrl,
|
||||||
|
Alt: cmd.Alt,
|
||||||
|
Command: cmd.Cmd,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
7
main.go
7
main.go
@ -24,9 +24,9 @@ type ObsConfig struct {
|
|||||||
Timeout int `flag:"timeout" help:"Timeout in seconds." default:"5" env:"OBS_TIMEOUT"`
|
Timeout int `flag:"timeout" help:"Timeout in seconds." default:"5" env:"OBS_TIMEOUT"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// cli is the main command line interface structure.
|
// CLI is the main command line interface structure.
|
||||||
// It embeds the ObsConfig struct to inherit its fields and flags.
|
// It embeds the ObsConfig struct to inherit its fields and flags.
|
||||||
type cli struct {
|
type CLI struct {
|
||||||
ObsConfig `embed:"" help:"OBS WebSocket configuration."`
|
ObsConfig `embed:"" help:"OBS WebSocket configuration."`
|
||||||
|
|
||||||
Man mangokong.ManFlag `help:"Print man page."`
|
Man mangokong.ManFlag `help:"Print man page."`
|
||||||
@ -43,6 +43,7 @@ type cli struct {
|
|||||||
Replaybuffer ReplayBufferCmd `help:"Manage replay buffer." cmd:"" aliases:"rb"`
|
Replaybuffer ReplayBufferCmd `help:"Manage replay buffer." cmd:"" aliases:"rb"`
|
||||||
Studiomode StudioModeCmd `help:"Manage studio mode." cmd:"" aliases:"sm"`
|
Studiomode StudioModeCmd `help:"Manage studio mode." cmd:"" aliases:"sm"`
|
||||||
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"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type context struct {
|
type context struct {
|
||||||
@ -57,7 +58,7 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
var cli cli
|
var cli CLI
|
||||||
ctx := kong.Parse(
|
ctx := kong.Parse(
|
||||||
&cli,
|
&cli,
|
||||||
kong.Name("GOBS-CLI"),
|
kong.Name("GOBS-CLI"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user