diff --git a/display/pkg/main.go b/display/pkg/main.go index fa5bac9..6a570bd 100644 --- a/display/pkg/main.go +++ b/display/pkg/main.go @@ -52,9 +52,13 @@ func GetDeviceMac() (string, error) { return "", fmt.Errorf("no suitable MAC address found") } -func OpenPresentation(path string) { +func OpenPresentation(path string) error { cmd := exec.Command("bash", "-c", "-r", fmt.Sprintf("soffice --show %s -nologo -norestore", path)) - _ = cmd.Run() + result := RunShellCommand(cmd) + if result.ExitCode != 0 { + return errors.New(result.Stderr) + } + return nil } func KeyboardInput(key int) error { diff --git a/display/web/main.go b/display/web/main.go index d1325c0..3b260c5 100644 --- a/display/web/main.go +++ b/display/web/main.go @@ -258,7 +258,11 @@ func openFileRoute(ctx echo.Context) error { imageTemplate(pathParam).Render(context.Background(), &templateBuffer) sseConnection <- templateBuffer.String() case ".pptx", ".odp": - pkg.OpenPresentation(fullPath) + err := pkg.OpenPresentation(fullPath) + if err != nil { + slog.Error("Failed to open presentation", "file", pathParam, "error", err) + return ctx.JSON(http.StatusInternalServerError, ErrorResponse{Error: "Failed to open presentation"}) + } default: return ctx.JSON(http.StatusBadRequest, ErrorResponse{Error: "Unsupported file type"}) }