Documentation
¶
Overview ¶
Package ext provides wrappers around external tools used by shotty.
All tool invocations go through the Runner interface, making them testable without actually executing external commands.
Index ¶
- type Action
- type ExecRunner
- func (ExecRunner) Output(ctx context.Context, name string, args ...string) ([]byte, error)
- func (ExecRunner) Run(ctx context.Context, name string, args ...string) error
- func (ExecRunner) RunWithStdin(ctx context.Context, stdin []byte, name string, args ...string) error
- func (ExecRunner) Signal(pid int, sig syscall.Signal) error
- func (ExecRunner) Start(ctx context.Context, name string, args ...string) (int, error)
- type Runner
- type Tools
- func (t *Tools) ConvertToMP4(ctx context.Context, input, output string) error
- func (t *Tools) GrimRegion(ctx context.Context, geometry, file string) ([]byte, error)
- func (t *Tools) NiriScreenshotScreen(ctx context.Context, path string) error
- func (t *Tools) NiriScreenshotWindow(ctx context.Context, path string) error
- func (t *Tools) Notify(ctx context.Context, summary, body string, timeout int, actions []Action) (string, error)
- func (t *Tools) NotifySimple(ctx context.Context, summary string, timeout int)
- func (t *Tools) PauseWfRecorder(pid int) error
- func (t *Tools) Satty(ctx context.Context, inputFile, outputFile string) error
- func (t *Tools) Slurp(ctx context.Context) (string, error)
- func (t *Tools) StartWfRecorder(ctx context.Context, geometry, file string, audio bool, audioDevice string) (int, error)
- func (t *Tools) StopWfRecorder(pid int) error
- func (t *Tools) WlCopy(ctx context.Context, data []byte, mimeType string) error
- func (t *Tools) WlCopyText(ctx context.Context, text string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExecRunner ¶
type ExecRunner struct{}
ExecRunner implements Runner using os/exec.
func (ExecRunner) RunWithStdin ¶
type Runner ¶
type Runner interface {
// Run executes a command and waits for it to finish.
Run(ctx context.Context, name string, args ...string) error
// Output executes a command and returns its stdout.
Output(ctx context.Context, name string, args ...string) ([]byte, error)
// RunWithStdin executes a command with data piped to stdin.
RunWithStdin(ctx context.Context, stdin []byte, name string, args ...string) error
// Start launches a command in the background and returns its PID.
Start(ctx context.Context, name string, args ...string) (int, error)
// Signal sends a signal to a process by PID.
Signal(pid int, sig syscall.Signal) error
}
Runner abstracts command execution for testability.
type Tools ¶
type Tools struct {
// contains filtered or unexported fields
}
Tools wraps external tool invocations with a Runner for testability.
func DefaultTools ¶
func DefaultTools() *Tools
DefaultTools creates a Tools instance that executes real commands.
func (*Tools) ConvertToMP4 ¶
ConvertToMP4 converts an AVI file to MP4 using ffmpeg.
func (*Tools) GrimRegion ¶
GrimRegion captures a region to file. If file is "", returns PNG data on stdout.
func (*Tools) NiriScreenshotScreen ¶
NiriScreenshotScreen captures the focused screen. Always copies to clipboard. If path is non-empty, also saves to file.
func (*Tools) NiriScreenshotWindow ¶
NiriScreenshotWindow captures the focused window. Always copies to clipboard. If path is non-empty, also saves to file.
func (*Tools) Notify ¶
func (t *Tools) Notify(ctx context.Context, summary, body string, timeout int, actions []Action) (string, error)
Notify sends a desktop notification with action buttons. Returns the selected action ID (empty if dismissed).
func (*Tools) NotifySimple ¶
NotifySimple sends a simple notification without actions.
func (*Tools) PauseWfRecorder ¶
PauseWfRecorder sends SIGUSR1 to toggle pause.
func (*Tools) Slurp ¶
Slurp prompts the user to select a screen region and returns the geometry string.
func (*Tools) StartWfRecorder ¶
func (t *Tools) StartWfRecorder(ctx context.Context, geometry, file string, audio bool, audioDevice string) (int, error)
StartWfRecorder starts wf-recorder and returns the PID.
func (*Tools) StopWfRecorder ¶
StopWfRecorder sends SIGINT to wf-recorder process.