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)
The two captured images will be different.
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.
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?
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. :)
(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?
A possibly relevant merge request was started @ https://invent.kde.org/graphics/spectacle/-/merge_requests/21
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
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.
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.
(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 :-)
(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...) :-(
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. :)
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.
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.
A possibly relevant merge request was started @ https://invent.kde.org/graphics/spectacle/-/merge_requests/23
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
(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.
> 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.
*** Bug 427210 has been marked as a duplicate of this bug. ***
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.
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