mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:27:34 +00:00
shot: Add ability to edit in PixelPaint
This commit is contained in:
parent
0cfcac7900
commit
f894e8be62
2 changed files with 10 additions and 1 deletions
|
@ -5,7 +5,7 @@ shot
|
|||
## Synopsis
|
||||
|
||||
```sh
|
||||
$ shot [--clipboard] [--delay seconds] [--screen index] [--region] [output]
|
||||
$ shot [--clipboard] [--delay seconds] [--screen index] [--region] [--edit] [output]
|
||||
```
|
||||
|
||||
## Options:
|
||||
|
@ -14,6 +14,7 @@ $ shot [--clipboard] [--delay seconds] [--screen index] [--region] [output]
|
|||
* `-d seconds`, `--delay seconds`: Seconds to wait before taking a screenshot
|
||||
* `-s index`, `--screen index`: The index of the screen (default: -1 for all screens)
|
||||
* `-r`, `--region`: Select a region to capture
|
||||
* `-e`, `--edit`: Open in PixelPaint
|
||||
|
||||
## Arguments:
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DateTime.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Process.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/Clipboard.h>
|
||||
#include <LibGUI/ConnectionToWindowServer.h>
|
||||
|
@ -95,6 +96,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
bool output_to_clipboard = false;
|
||||
unsigned delay = 0;
|
||||
bool select_region = false;
|
||||
bool edit_image = false;
|
||||
int screen = -1;
|
||||
|
||||
args_parser.add_positional_argument(output_path, "Output filename", "output", Core::ArgsParser::Required::No);
|
||||
|
@ -102,6 +104,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.add_option(delay, "Seconds to wait before taking a screenshot", "delay", 'd', "seconds");
|
||||
args_parser.add_option(screen, "The index of the screen (default: -1 for all screens)", "screen", 's', "index");
|
||||
args_parser.add_option(select_region, "Select a region to capture", "region", 'r');
|
||||
args_parser.add_option(edit_image, "Open in PixelPaint", "edit", 'e');
|
||||
|
||||
args_parser.parse(arguments);
|
||||
|
||||
|
@ -152,6 +155,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
warnln("Failed to encode PNG");
|
||||
return 1;
|
||||
}
|
||||
if (edit_image)
|
||||
output_path = Core::DateTime::now().to_string("/tmp/screenshot-%Y-%m-%d-%H-%M-%S.png"sv);
|
||||
|
||||
auto file_or_error = Core::File::open(output_path, Core::OpenMode::ReadWrite);
|
||||
if (file_or_error.is_error()) {
|
||||
|
@ -165,6 +170,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (edit_image)
|
||||
TRY(Core::Process::spawn("/bin/PixelPaint"sv, Array { output_path }));
|
||||
|
||||
bool printed_hyperlink = false;
|
||||
if (isatty(STDOUT_FILENO)) {
|
||||
auto full_path = Core::File::real_path_for(output_path);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue