Bug 425995 - CLI options are missing the ability to exclude window decorations
Summary: CLI options are missing the ability to exclude window decorations
Status: RESOLVED FIXED
Alias: None
Product: Spectacle
Classification: Applications
Component: General (show other bugs)
Version: 18.12.2
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Boudhayan Gupta
URL:
Keywords: junior-jobs
: 427210 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-08-30 16:59 UTC by Karl Robillard
Modified: 2020-10-12 16:09 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 20.12


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Karl Robillard 2020-08-30 16:59:23 UTC
SUMMARY
The includeDecorations option cannot be set from the command line so different images will be captured based on how this is configured in the GUI.

STEPS TO REPRODUCE
1. Capture image from command line (spectacle -a -b -o /tmp/shot1.png)
2. Change the "Include window titlebar and borders" option in the GUI.
3. Capture image from command line (spectacle -a -b -o /tmp/shot2.png)

OBSERVED RESULT
The two captured images will be different.


EXPECTED RESULT
Using the same CLI options should always produce the same images.

I'm not sure if same variation occurs with the includePointer option, but this should be controllable from the CLI as well.

My preference for CLI defaults would be that both include* options are disabled by default.
Comment 1 Nazar Kalinowski 2020-09-12 15:14:01 UTC
I am willing to work on this, but I would like to hear from spectacle's developers which way should it be done?

Currently, in the background mode, values for including pointer/decorations are taken from the config.
Should we replace it with default values (if yes: what would be a good default? both false? false for pointer and true for decorations?) and add some CLI options like "--[not]-include-[pointer/decorations]" (depending on what is the default)?
Or is there a better way?

P.S. Is there a consensus regarding dashes for long options in KDE? I see that sometimes it's "longoption" and sometimes "long-option", which one should be the preferred one?
Comment 2 Nate Graham 2020-09-12 17:54:09 UTC
In the background mode, it should probably read the default value form the config file, unless you use the proposed new option to force them on or off.

As for the style, I'd say just copy what's already done. Spectacle supports both styles, so do that. :)
Comment 3 Nazar Kalinowski 2020-09-12 18:36:45 UTC
(In reply to Nate Graham from comment #2)
> In the background mode, it should probably read the default value form the
> config file, unless you use the proposed new option to force them on or off.
> 
> As for the style, I'd say just copy what's already done. Spectacle supports
> both styles, so do that. :)

So, 4 new options would be okay?
Comment 4 Bug Janitor Service 2020-09-13 05:14:33 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/spectacle/-/merge_requests/21
Comment 5 Nate Graham 2020-09-14 21:02:51 UTC
Git commit 0b3bb8a60ae70115d86b60d43a3df2ddcbded46c by Nate Graham, on behalf of Nazar Kalinowski.
Committed on 14/09/2020 at 21:01.
Pushed by ngraham into branch 'master'.

Add CLI options for including pointer/decorations

M  +18   -1    src/SpectacleCore.cpp

https://invent.kde.org/graphics/spectacle/commit/0b3bb8a60ae70115d86b60d43a3df2ddcbded46c
Comment 6 Karl Robillard 2020-09-19 02:05:45 UTC
Thanks for the fix, but this seems a rather messy way to go about it.

Since there are no independent default values for the CLI you are forcing the user to use these options, but that is something they will only discover after finding out that the behavior is still inconsistent.  It is unfortunate the the title of the bug was changed from "includeDecorations option makes CLI use unreliable" as that problem still exists for certain use cases.

Consider this:
  1. User adds a spectacle line to a script without the new options and tests that it runs as expected (window contents & decorations).
  2. User tweaks the setting in the GUI some days later for another project, not thinking about the script.
  2. User runs said script a week later and spends time troubleshooting why the screenshot now has no decorations.

This partial fix not only requires CLI users to use the new options, it appears that there are no short versions so they must be verbose.

It also appears that these new options are the only ones that have enable/disable versions, which makes them inconsistent with existing options such as --gui and --nonotify.  Why are there no opposite options --no-gui or --notify for those?

Apologies if I misinterpreted what that commit does, but I think that:
  1. There should be default values for the CLI (as is done with -g and -n).
  2. There should be short versions of the options.
Comment 7 Nate Graham 2020-09-21 04:35:37 UTC
Thoughts, Nazar?
Comment 8 Nazar Kalinowski 2020-09-21 13:21:35 UTC
(In reply to Nate Graham from comment #7)
> Thoughts, Nazar?

Speaking honestly, I wdon't know :-(

What Karl says about defaults for the settings makes sense to me, but I am definitely not the one who should decide this.
Regarding the short options, how do we cheese what should they be? Do we just take the first available letters from the alphabet? I doubt it's possible to find "meaningful" ones in this case.

But whatever the short decision is going to be, I'm willing to implement it :-)
Comment 9 Nazar Kalinowski 2020-09-21 13:28:18 UTC
(In reply to Nazar Kalinowski from comment #8)
> wdon't = don't
> cheese = choose
> short decision = final decision (don't ask how)

I promise to not write a response from my phone ever again (or at least to check it before sending...) :-(
Comment 10 Nate Graham 2020-09-21 14:54:42 UTC
If other CLI options have a default mode, we could emulate that here.

Regarding shorter option options (lol), that's tricky because we're running out of reasonable letters. :)
Comment 11 Karl Robillard 2020-09-21 21:25:51 UTC
When you can break compatibility I would recommend consolidating the Area options to free up some letters with something like this:

  -a, --area <window|window-under|screen|all|rect>  Area to Capture (default all)

That would also make it clear that these are mutually exclusive.  But for right now how about removing the --no-include* options leaving:

  -e, --include-decorations Include window decorations in the screenshot
  -p, --include-pointer     Include pointer in the screenshot

'e' is for the [E]nclosing window d[E]corations and [E]mbellishments of course.

You might consider using "--show-" instead of "--include-" to make the long options shorter as that language is used in the Tool Tips, but then it would not match the checkbox labels as well.
Comment 12 David Redondo 2020-09-22 06:40:31 UTC
I agree, best would be to define a default behavior (I would go for including decorations and hiding the pointer, the default values of those settings) and then provide command line options to override those.

In my mind the options in main window of spectacle are specific to the the screenshots taken from there and should not apply to the cli.
Comment 13 Bug Janitor Service 2020-09-22 07:22:13 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/spectacle/-/merge_requests/23
Comment 14 David Redondo 2020-09-22 07:25:31 UTC
This merge request makes it so that by default the pointer is excluded and window decorations captured (the default values for the gui). 

You can pass '-p/--pointer' and '--nd, --no-decorations' to change it
Comment 15 Karl Robillard 2020-09-22 14:47:17 UTC
(In reply to David Redondo from comment #14)
> This merge request makes it so that by default the pointer is excluded and
> window decorations captured (the default values for the gui). 
> 
> You can pass '-p/--pointer' and '--nd, --no-decorations' to change it

That seems closer to an ideal solution except that I can't recall ever seeing two long options for an option.  Is that something which is common in KDE?  Does the KDE argument parser allow you to group short options like GNU (e.g. -ab for -a -b)?

I'd also recommend adding a comment where the default values are set to note that those match the default GUI values.
Comment 16 David Redondo 2020-09-22 14:56:09 UTC
> 
> That seems closer to an ideal solution except that I can't recall ever
> seeing two long options for an option.  Is that something which is common in
> KDE?  Does the KDE argument parser allow you to group short options like GNU
> (e.g. -ab for -a -b)?
Initially I wanted to have "-nd" but you are right that it is equivalent to -n -d and QCommandLineParser doesn't seem to allow something like that. Maybe "-e/--no-decorations" is better and makes sense with the description "Exclude decorations"


> I'd also recommend adding a comment where the default values are set to note
> that those match the default GUI values.
Comment 17 Antonio Prcela 2020-10-04 21:12:23 UTC
*** Bug 427210 has been marked as a duplicate of this bug. ***
Comment 18 irchaika 2020-10-10 16:54:20 UTC
tried to look at other cli tools for reference, but scrot uses -b for borders (which is already used for --background here). I, for one, like the suggested -e over --no-decoration, I consider it would work better, specially in short mode.
Comment 19 Nate Graham 2020-10-12 16:09:48 UTC
Git commit ba2b192a75e9103faf218e3a86900293cd9e9a94 by Nate Graham, on behalf of David Redondo.
Committed on 12/10/2020 at 16:09.
Pushed by ngraham into branch 'master'.

Use default value for including decorations and pointer in background mode

Uses the same default value as the gui. Provide short flags for changing the
default behavior (-p and --nd).

M  +6    -12   src/SpectacleCore.cpp

https://invent.kde.org/graphics/spectacle/commit/ba2b192a75e9103faf218e3a86900293cd9e9a94