screenshot

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 38 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package screenshot is the screenshot host (crates/lys-shell/src/shell/screenshot) behind the dev.stubbe.lys.Screenshot1 D-Bus service: it resolves the capture target (opening the freeze-frame region overlay for region mode), captures a full-resolution image, saves a PNG, optionally copies it to the clipboard and fires a desktop notification, and replies with the path. It also hosts the color pick the portal's Screenshot.PickColor reuses: freeze every output, then the loupe.

Index

Constants

View Source
const (
	ServiceName = "dev.stubbe.lys.Screenshot1"
	ServicePath = "/dev/stubbe/lys/Screenshot"
)

D-Bus identity (wayle-ipc's screenshot proxy).

View Source
const (
	ModeRegion = "region"
	ModeOutput = "output"
	ModeScreen = "screen"
	ModeWindow = "window"
)

The capture modes of Capture: a drag-selected region, one output (the focused one without a target), the whole multi-monitor space composited, or the active window.

Variables

ErrBusy answers a capture or a color pick refused because another capture is in progress: nothing opened, nothing was captured, and what was running goes on untouched. It is neither a capture nor the user's cancel.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client calls the daemon: the `lys-shell screenshot` CLI, and the portal backend's Screenshot and PickColor.

func NewClient

func NewClient(conn *dbus.Conn) *Client

NewClient addresses the daemon over conn.

func (*Client) Capture

func (c *Client) Capture(ctx context.Context, caller portaldialogs.Caller, mode, target string) (string, error)

Capture asks the shell for a screenshot; see Daemon.Capture. A refused request is ErrBusy.

func (*Client) CapturePrivate

func (c *Client) CapturePrivate(ctx context.Context, caller portaldialogs.Caller, mode, target string, pointer bool) (string, error)

CapturePrivate asks the shell for an app's screenshot; see Daemon.CapturePrivate. A refused request is ErrBusy.

func (*Client) Dismiss

func (c *Client) Dismiss(ctx context.Context, handle string) error

Dismiss cancels the selection or pick showing for the request at handle.

func (*Client) PickColor

func (c *Client) PickColor(ctx context.Context, caller portaldialogs.Caller) (color [3]float64, picked bool, err error)

PickColor asks the shell for an interactive color pick; picked is false for the user's cancel, and a refused request is ErrBusy.

type CompositorFocus

type CompositorFocus struct {
	Hyprland *hyprland.Connection
}

CompositorFocus asks Hyprland (when Hyprland is set), then lys-wm, then mango, then niri - the Rust host's order with lys-wm added. The focused output also comes from sway's and niri's focused workspace.

func (CompositorFocus) ActiveWindow

func (f CompositorFocus) ActiveWindow() windowTarget

ActiveWindow implements Focus.

func (CompositorFocus) FocusedOutput

func (f CompositorFocus) FocusedOutput() (string, bool)

FocusedOutput implements Focus.

func (CompositorFocus) Windows

func (f CompositorFocus) Windows() []image.Rectangle

Windows is what the region overlay's click picks from: the visible windows' global logical rectangles, topmost first, from Hyprland, lys-wm or sway; none from niri and mango, which report no window geometry, so a click there picks the output.

type Daemon

type Daemon struct {
	// contains filtered or unexported fields
}

Daemon exports a Host as dev.stubbe.lys.Screenshot1.

func NewDaemon

func NewDaemon(h *Host) *Daemon

NewDaemon wraps the host for export.

func (*Daemon) Capture

func (d *Daemon) Capture(c portaldialogs.Caller, mode, target string) (string, *dbus.Error)

Capture captures a screenshot and blocks until it is saved or cancelled. mode is region, output, screen, or window; target is an output connector name (output mode), a window's ext toplevel identifier (window mode; the active window when empty), or empty. Replies the saved PNG path, empty when a region selection was cancelled or dismissed; every mode fails with the Busy error while a capture overlay is open.

func (*Daemon) CapturePrivate

func (d *Daemon) CapturePrivate(c portaldialogs.Caller, mode, target string, pointer bool) (string, *dbus.Error)

CapturePrivate captures a screenshot for an app as Capture does, to a private file and with none of the user's save, clipboard or notification settings; pointer composites the pointer in.

func (*Daemon) Dismiss

func (d *Daemon) Dismiss(handle string) *dbus.Error

Dismiss cancels the region selection or color pick showing for the request at handle.

func (*Daemon) Export

func (d *Daemon) Export(conn *dbus.Conn) (func(), error)

Export exports the object and claims the well-known name; the returned release drops the name.

func (*Daemon) PickColor

func (d *Daemon) PickColor(c portaldialogs.Caller) (bool, float64, float64, float64, *dbus.Error)

PickColor picks one screen color interactively, replying whether the user picked one and its sRGB (r, g, b) in [0, 1]; a failure is an error, the Busy error while a capture overlay is open.

type Focus

type Focus interface {
	// FocusedOutput is the focused output's connector name; false lets
	// the capture fall back to the first output.
	FocusedOutput() (string, bool)
	// ActiveWindow identifies the focused window; the zero target
	// matches nothing.
	ActiveWindow() windowTarget
}

Focus resolves what the output and window modes capture: the focused output and the active window, from whichever compositor is running (screenshot/mod.rs's focused_output_name and active_window_target).

type Host

type Host struct {
	// Config is the [modules.screenshot] section in effect, read at
	// each save so a reload applies to the next capture.
	Config func() config.ScreenshotConfig
	// Monitors lists the outputs' logical geometry, for scaling
	// selections and compositing the whole screen.
	Monitors func() []regionoverlay.Monitor
	// Gate is the capture gate Region and Picker share: every capture of
	// this host is admitted by it, so none runs while an overlay is open.
	Gate *regionoverlay.Gate
	// Region and Picker are the freeze-frame overlays.
	Region interface {
		Request(ctx context.Context, frames regionoverlay.Frames) (regionoverlay.Selection, bool, error)
	}
	Picker interface {
		Request(ctx context.Context, frames regionoverlay.Frames) (colorpicker.RGB, bool, error)
	}
	// Focus resolves the focused output and the active window.
	Focus Focus
	// Copy puts an image on the clipboard; nil disables the copy.
	Copy func(image.Image) error
	// Notify announces a saved screenshot, and a failed copy with it;
	// nil sends the desktop notification.
	Notify func(Notice)
	// Forget drops the GPU textures of the frozen frames with these
	// identities, once the overlay that drew them has closed.
	Forget func(ids []render.ImageID)
	// contains filtered or unexported fields
}

Host performs captures. The capture half runs on the caller's goroutine (a D-Bus handler); the overlays marshal onto the lys-ui loop themselves.

func (*Host) Capture

func (h *Host) Capture(c portaldialogs.Caller, mode, target string) (string, error)

Capture takes a screenshot for the user and returns the saved PNG path, or "" when the user cancelled a region selection. It is saved where [modules.screenshot] says, then copied and announced as it says. Every mode answers ErrBusy while a capture overlay is open.

func (*Host) CapturePrivate

func (h *Host) CapturePrivate(c portaldialogs.Caller, mode, target string, pointer bool) (string, error)

CapturePrivate takes a screenshot for an app: saved to a file of its own in lys-shell's cache, with none of the user's save, clipboard or notification settings applied, the pointer composited in when pointer is set. "" is a cancelled selection; every mode answers ErrBusy while a capture overlay is open.

func (*Host) Dismiss

func (h *Host) Dismiss(handle string)

Dismiss cancels the overlay open for the request at handle; another request's stays.

func (*Host) PickColor

func (h *Host) PickColor(caller portaldialogs.Caller) (color [3]float64, picked bool, err error)

PickColor freezes every output and lets the user pick one pixel with the loupe, returning sRGB channels in [0, 1]; picked is false when the user cancelled, ErrBusy answers while a capture overlay is open, and any other error is a failure.

type Notice added in v0.2.0

type Notice struct {
	Summary string
	Body    string
	Icon    string
}

Notice is the desktop notification announcing a saved screenshot.

Jump to

Keyboard shortcuts

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