ext

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	ID    string
	Label string
}

Action represents a notification action button.

type ExecRunner

type ExecRunner struct{}

ExecRunner implements Runner using os/exec.

func (ExecRunner) Output

func (ExecRunner) Output(ctx context.Context, name string, args ...string) ([]byte, error)

func (ExecRunner) Run

func (ExecRunner) Run(ctx context.Context, name string, args ...string) error

func (ExecRunner) RunWithStdin

func (ExecRunner) RunWithStdin(ctx context.Context, stdin []byte, name string, args ...string) error

func (ExecRunner) Signal

func (ExecRunner) Signal(pid int, sig syscall.Signal) error

func (ExecRunner) Start

func (ExecRunner) Start(ctx context.Context, name string, args ...string) (int, error)

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 NewTools

func NewTools(r Runner) *Tools

NewTools creates a Tools instance with the given Runner.

func (*Tools) ConvertToMP4

func (t *Tools) ConvertToMP4(ctx context.Context, input, output string) error

ConvertToMP4 converts an AVI file to MP4 using ffmpeg.

func (*Tools) GrimRegion

func (t *Tools) GrimRegion(ctx context.Context, geometry, file string) ([]byte, error)

GrimRegion captures a region to file. If file is "", returns PNG data on stdout.

func (*Tools) NiriScreenshotScreen

func (t *Tools) NiriScreenshotScreen(ctx context.Context, path string) error

NiriScreenshotScreen captures the focused screen. Always copies to clipboard. If path is non-empty, also saves to file.

func (*Tools) NiriScreenshotWindow

func (t *Tools) NiriScreenshotWindow(ctx context.Context, path string) error

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

func (t *Tools) NotifySimple(ctx context.Context, summary string, timeout int)

NotifySimple sends a simple notification without actions.

func (*Tools) PauseWfRecorder

func (t *Tools) PauseWfRecorder(pid int) error

PauseWfRecorder sends SIGUSR1 to toggle pause.

func (*Tools) Satty

func (t *Tools) Satty(ctx context.Context, inputFile, outputFile string) error

Satty opens the screenshot editor.

func (*Tools) Slurp

func (t *Tools) Slurp(ctx context.Context) (string, error)

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

func (t *Tools) StopWfRecorder(pid int) error

StopWfRecorder sends SIGINT to wf-recorder process.

func (*Tools) WlCopy

func (t *Tools) WlCopy(ctx context.Context, data []byte, mimeType string) error

WlCopy copies data to clipboard with the given MIME type.

func (*Tools) WlCopyText

func (t *Tools) WlCopyText(ctx context.Context, text string) error

WlCopyText copies text to clipboard.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL