Handle relative paths for the screenshot rc command correctly

This commit is contained in:
Kovid Goyal 2026-07-08 17:26:41 +05:30
parent eed972d441
commit 55015c8a4a
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 2 deletions

View file

@ -110,7 +110,7 @@ class Screenshot(RemoteCommand):
if output_path:
with open(os.path.expanduser(output_path), 'wb') as f:
f.write(png_data)
responder.send_data(True)
responder.send_data(f'Screenshot saved to: {os.path.abspath(f.name)}')
else:
responder.send_data(standard_b64encode(png_data).decode('ascii'))
except Exception as e:

View file

@ -5,6 +5,7 @@ package at
import (
"fmt"
"os"
"path/filepath"
"github.com/emmansun/base64"
)
@ -32,7 +33,11 @@ func read_screenshot_args(io_data *rc_io_data, args []string) (func(io_data *rc_
// io_data.rc.Payload is only populated after this generator is created,
// so the payload field must be set here rather than above.
if len(args) == 1 {
set_payload_string_field(io_data, "Output_path", args[0])
path, err := filepath.Abs(args[0])
if err != nil {
return false, fmt.Errorf("%s is not a valid path with error: %w", args[0], err)
}
set_payload_string_field(io_data, "Output_path", path)
}
return true, nil
}, nil