add image capturing for linux

This commit is contained in:
KingKDot
2026-04-03 13:24:49 -05:00
parent 2d21f6803c
commit 37bb3aabd7
3 changed files with 42 additions and 4 deletions
@@ -4,10 +4,18 @@ package capture
import (
"image"
"github.com/kbinani/screenshot"
)
var activeDisplays = func() int { return 0 }
var activeDisplays = func() int {
return screenshot.NumActiveDisplays()
}
var captureDisplayFn = func(int) (*image.RGBA, error) { return nil, nil }
var captureDisplayFn = func(display int) (*image.RGBA, error) {
return screenshot.CaptureDisplay(display)
}
func displayCount() int { return 0 }
func displayCount() int {
return screenshot.NumActiveDisplays()
}
@@ -0,0 +1,30 @@
//go:build linux
package capture
import (
"image"
"github.com/kbinani/screenshot"
)
func displayBounds(idx int) image.Rectangle {
return screenshot.GetDisplayBounds(idx)
}
func displayScale(idx int) float64 {
return 1.0
}
func MonitorInfos() []MonitorInfo {
n := screenshot.NumActiveDisplays()
infos := make([]MonitorInfo, 0, n)
for i := 0; i < n; i++ {
b := screenshot.GetDisplayBounds(i)
infos = append(infos, MonitorInfo{
Width: b.Dx(),
Height: b.Dy(),
})
}
return infos
}
@@ -1,4 +1,4 @@
//go:build !windows
//go:build !windows && !linux
package capture