From 4771a5616413a169bd829d617d85dbe46b61dd16 Mon Sep 17 00:00:00 2001 From: 2mal3 <56305732+2mal3@users.noreply.github.com> Date: Tue, 21 Oct 2025 22:17:15 +0200 Subject: [PATCH] chore(display): support multiple screenshot tools --- display/pkg/main.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/display/pkg/main.go b/display/pkg/main.go index 3ea335c..fa5bac9 100644 --- a/display/pkg/main.go +++ b/display/pkg/main.go @@ -4,6 +4,7 @@ import ( "bytes" "errors" "fmt" + "log/slog" "net" "os" "os/exec" @@ -73,12 +74,19 @@ func KeyboardInput(key int) error { func TakeScreenshot() (string, error) { tempFilePath := filepath.Join(os.TempDir(), fmt.Sprintf("screenshot_%d.png", time.Now().Unix())) - cmd := exec.Command("gnome-screenshot", "-f", tempFilePath) - commandOutput := RunShellCommand(cmd) - if commandOutput.ExitCode != 0 { - return "", errors.New(commandOutput.Stderr) + cmds := []*exec.Cmd{ + exec.Command("gnome-screenshot", "-f", tempFilePath), + exec.Command("xfce4-screenshooter", "-f", "-s", tempFilePath), + exec.Command("spectacle", "--fullscreen", "--background", "--output", tempFilePath), } - return tempFilePath, nil + for _, cmd := range cmds { + commandOutput := RunShellCommand(cmd) + if commandOutput.ExitCode == 0 { + return tempFilePath, nil + } + slog.Warn("Screenshot error", "error", commandOutput.Stderr) + } + return "", errors.New("no screenshot utility found or all failed") } func RunShellCommand(cmd *exec.Cmd) CommandResponse {