forked from openatx/atx-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscreenshot.go
40 lines (36 loc) · 995 Bytes
/
screenshot.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"encoding/json"
"fmt"
"log"
"github.com/pkg/errors"
)
func screenshotWithMinicap(filename, thumbnailSize string) (err error) {
output, err := runShellOutput("LD_LIBRARY_PATH=/data/local/tmp", "/data/local/tmp/minicap", "-i")
if err != nil {
return
}
var f MinicapInfo
if er := json.Unmarshal([]byte(output), &f); er != nil {
err = fmt.Errorf("minicap not supported: %v", er)
return
}
if thumbnailSize == "" {
thumbnailSize = fmt.Sprintf("%dx%d", f.Width, f.Height)
}
if _, err = runShell(
"LD_LIBRARY_PATH=/data/local/tmp",
"/data/local/tmp/minicap",
"-P", fmt.Sprintf("%dx%d@%s/%d", f.Width, f.Height, thumbnailSize, f.Rotation),
"-s", ">"+filename); err != nil {
err = errors.Wrap(err, "minicap")
return
}
return nil
}
func screenshotWithScreencap(filename string) (err error) {
output, err := runShellOutput("screencap", "-p", filename)
err = errors.Wrap(err, "screencap")
log.Printf("screencap: %s, %v", output, err)
return
}