mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-08-04 06:36:24 +00:00
Handle relative paths for the screenshot rc command correctly
This commit is contained in:
parent
eed972d441
commit
55015c8a4a
2 changed files with 7 additions and 2 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue