-
-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add write-to-disk argument to screenshot actions #975
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks reasonable. Some small changes.
It was fairly straightforward but I would probably want to add a test. Where do you think that would go?
Hm, not sure what you can usefully and reasonably easily test here. What did you have in mind?
An alternative that I thought about at the end is to store the screenshot in the tmp directory instead if !write_to_disk, because my understanding is that in order to show an image preview in the notification we still need a file on disk somewhere.
There are actually some other ways to show an image: https://specifications.freedesktop.org/notification-spec/latest/icons-and-images.html But you'd need to check the actual notification daemons like mako to see what they support.
Anyhow I don't think we should save to /tmp, at least not in this PR. Maybe something for later after considering our options.
Also, maybe we should rename save_screenshot since the name may be a bit misleading now.
Hmm, I guess, but I don't immediately have any good name suggestions so let's leave it as is.
niri-ipc/src/lib.rs
Outdated
ScreenshotScreen {}, | ||
ScreenshotScreen { | ||
/// Save the screenshot in addition to putting it in your clipboard. | ||
#[cfg_attr(feature = "clap", arg(short, long, action = clap::ArgAction::Set, default_value_t = true))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this look on the CLI? Do you have to do --write-to-disk=false
? Or is there a --no-write-to-disk
? Could you show what the help looks like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ cargo r -- msg action screenshot-screen --help
Screenshot the focused screen
Usage: niri msg action screenshot-screen [OPTIONS]
Options:
-w, --write-to-disk <WRITE_TO_DISK> Save the screenshot in addition to putting it in your clipboard [default: true] [possible values: true, false]
-h, --help Print help
so you would do niri msg action screenshot-window --write-to-disk false
(or -w false
). --no-write-to-disk
would probably also work, I'd have to look at clap but I would be surprised if they don't support it. I think screenshot-window -w false
is a bit more intuitive in short form but I don't have strong opinions here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently clap does not support automatic --no-XYZ
flags (clap-rs/clap#815) so we would have to do it manually. I can implement that if you want. As I said, I have no strong opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh, I suppose it's fine as is then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bikeshed: should the short flag be -d for disk perhaps rather than -w for write? Or would that be more confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-d
also works. I think it's fine to change it later if another flag is added that fits better, especially for the short flag.
ad9a80c
to
920ef71
Compare
No, you're right, I'm also having trouble figuring out what would be tested. |
920ef71
to
0d7a174
Compare
That should be all review comments. |
Missed the: "The screenshot is saved according to the |
Sorry, I can't find where that would be. (I tried grepping for it.) |
My suggested change from earlier: #975 (comment) |
Oh! I misunderstood the diff. Sorry about that. |
0d7a174
to
f09b62f
Compare
|
Thanks! |
Closes #916
I added a
write_to_disk: bool
parameter to most of the screenshot actions and a condition insave_screenshot
. It was fairly straightforward but I would probably want to add a test. Where do you think that would go?An alternative that I thought about at the end is to store the screenshot in the
tmp
directory instead if!write_to_disk
, because my understanding is that in order to show an image preview in the notification we still need a file on disk somewhere. That would be very easy to implement since all of the parameter stuff would be the same.Also, maybe we should rename
save_screenshot
since the name may be a bit misleading now.Let me know what you think!