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
- Variables
- type Client
- func (c *Client) Capture(ctx context.Context, caller portaldialogs.Caller, mode, target string) (string, error)
- func (c *Client) CapturePrivate(ctx context.Context, caller portaldialogs.Caller, mode, target string, ...) (string, error)
- func (c *Client) Dismiss(ctx context.Context, handle string) error
- func (c *Client) PickColor(ctx context.Context, caller portaldialogs.Caller) (color [3]float64, picked bool, err error)
- type CompositorFocus
- type Daemon
- func (d *Daemon) Capture(c portaldialogs.Caller, mode, target string) (string, *dbus.Error)
- func (d *Daemon) CapturePrivate(c portaldialogs.Caller, mode, target string, pointer bool) (string, *dbus.Error)
- func (d *Daemon) Dismiss(handle string) *dbus.Error
- func (d *Daemon) Export(conn *dbus.Conn) (func(), error)
- func (d *Daemon) PickColor(c portaldialogs.Caller) (bool, float64, float64, float64, *dbus.Error)
- type Focus
- type Host
- func (h *Host) Capture(c portaldialogs.Caller, mode, target string) (string, error)
- func (h *Host) CapturePrivate(c portaldialogs.Caller, mode, target string, pointer bool) (string, error)
- func (h *Host) Dismiss(handle string)
- func (h *Host) PickColor(caller portaldialogs.Caller) (color [3]float64, picked bool, err error)
- type Notice
Constants ¶
const ( ServiceName = "dev.stubbe.lys.Screenshot1" ServicePath = "/dev/stubbe/lys/Screenshot" )
D-Bus identity (wayle-ipc's screenshot proxy).
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 ¶
var ErrBusy = regionoverlay.ErrBusy
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 (*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.
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 (*Daemon) Capture ¶
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 ¶
Dismiss cancels the region selection or color pick showing for the request at handle.
func (*Daemon) Export ¶
Export exports the object and claims the well-known name; the returned release drops the name.
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 ¶
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 ¶
Dismiss cancels the overlay open for the request at handle; another request's stays.