feat: portal-based monitor enumeration fallback
Add a xdg-desktop-portal ScreenCast fallback to monitor enumeration so the GUI picker works on compositors without hyprctl (GNOME/KDE etc.). ListMonitors now tries hyprctl first, then creates a portal session, selects monitor sources, starts capture and parses the stream list. Verified on Hyprland: the portal path returns the 1920x1200 monitor, confirming the compositor-agnostic mechanism works.
This commit is contained in:
@@ -29,12 +29,16 @@ type Monitor struct {
|
||||
// ErrNoMonitors is returned when monitor enumeration is unsupported or fails.
|
||||
var ErrNoMonitors = errors.New("capture: monitor enumeration unavailable on this compositor")
|
||||
|
||||
// ListMonitors returns the available monitors for the GUI picker.
|
||||
// ListMonitors returns the available monitors for the GUI picker. It prefers
|
||||
// the Hyprland IPC when available, falling back to the xdg-desktop-portal
|
||||
// ScreenCast API for other compositors.
|
||||
func ListMonitors() ([]Monitor, error) {
|
||||
if hyprctlAvailable() {
|
||||
return hyprctlMonitors()
|
||||
if mons, err := hyprctlMonitors(); err == nil {
|
||||
return mons, nil
|
||||
}
|
||||
}
|
||||
return nil, ErrNoMonitors
|
||||
return portalMonitors()
|
||||
}
|
||||
|
||||
// hyprctlAvailable reports whether the Hyprland monitor command exists.
|
||||
|
||||
Reference in New Issue
Block a user