Saving all screenshots as "Screenshot_%Y%D....png" doesn't scale too well with a large number of screenshots (think of QA people), and doesn't make it easy to find them.
Instead, in the configuration it would be nice to have the active window's title to be an available option for the suggested file name. E.G.: %W.
This way, a user (or a default setting) could set the file name template to read something as follows:
%W %Y-%M-%D %H.%m.png
For the current window on bugs.kde.org, it would result in:
"Enter Bug: Spectacle - Chromium - 2017-01-01 11.30.png"
I'm going to implement this. I found that one way to get active window's title is to use xdotool. Is it OK to add additional dependency?
good to see you here, didn't know you already picked a bug when I wrote my comment in D10683 ;)
I think skaumo got a great idea and it makes sense to implement this feature. (Some ideas in Bugzilla are not so great, so in the future just ask before starting on something, e.g. by opening a task for discussion on https://phabricator.kde.org/project/view/78/).
> one way to get active window's title is to use xdotool
In general calling external binaries is not the best idea. Could you try to find a C/C++ API for this, e.g. similar to what Spectacle is doing in "src/PlatformBackends/" to get to the image of the screen?
I think there must be a way, because e.g. KWin and Plasma's taskbar can show the window title too. Perhaps ask on IRC for tips (but keep in mind that Spectacle must work in a non-Plasma environment too).
Git commit d47ab66eb9a2a0ce7a62dabbc3bf632898186b8e by Roman Inflianskas.
Committed on 06/03/2018 at 16:43.
Pushed by romaninflianskas into branch 'master'.
Add optional window title to filename templates
Add '%T' placeholder for filename pattern to insert window title.
Example filenames for pattern `%Y-%M-%D %H-%m-%S. %T`:
2018-02-21 19-11-55. romas : byobu.png
Example filenames for pattern `%T`:
romas : byobu.png
# Go to `Configure... -> Save`.
# Enter to `Default Save Filename -> Filename` tempate `%Y-%M-%D %H-%m-%S. %T`.
# Press `OK`.
# Save screenshot.
# Observe that screenshot filename matches pattern.
Examples of filenames with empty window title:
> | Input | Result |
> | --- | --- |
> | Screenshot_%T_ProjectX | Screenshot_ProjectX |
> | %T_ProjectX | ProjectX |
> | Screenshot_%T | Screenshot |
> | %T | Screenshot |
Reviewers: rkflx, #spectacle
Reviewed By: rkflx, #spectacle
Subscribers: ngraham, rkflx
Maniphest Tasks: T8036
Differential Revision: https://phabricator.kde.org/D10709
M +1 -0 doc/index.docbook
M +68 -13 src/ExportManager.cpp
M +11 -0 src/ExportManager.h
M +3 -1 src/Gui/SettingsDialog/SaveOptionsPage.cpp
M +1 -0 src/PlatformBackends/ImageGrabber.h
M +16 -2 src/PlatformBackends/X11ImageGrabber.cpp
M +1 -0 src/PlatformBackends/X11ImageGrabber.h
M +4 -2 src/SpectacleCore.cpp