Bug 484211 - Spectacle should convert old format string in filename
Summary: Spectacle should convert old format string in filename
Status: RESOLVED FIXED
Alias: None
Product: Spectacle
Classification: Applications
Component: General (show other bugs)
Version: 24.02.1
Platform: Arch Linux Linux
: NOR major
Target Milestone: ---
Assignee: Noah Davis
URL:
Keywords:
: 486995 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-03-22 06:28 UTC by gudvinr+kde
Modified: 2024-06-20 06:59 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 24.05.2
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gudvinr+kde 2024-03-22 06:28:19 UTC
SUMMARY

After an update, spectacle started using Qt date format (apparently) instead of printf.
This broke custom filename strings. So, instead of "20240-03-22 01.01.01.png" I get "%Y-%M-%D %H.%m.%S.png"

Spectacle should either fallback to printf, when it sees "old" formatting, or convert that to "<yyyy>-<MM>-<dd> <hh>.<mm>.<ss>.png" to make names look the same.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.0.2
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2
Kernel Version: 6.6.22-1-lts (64-bit)
Graphics Platform: X11
Comment 1 Noah Davis 2024-03-24 23:45:52 UTC
There was a configuration migration script to automatically convert old format filename templates if your config file was created before 2024-02-28T00:00:00Z (roughly the release date/time of 24.02). I don't think we have a way to get the version we're upgrading from, so we used the age of the config file. I did test the script before release, but it's possible that the script wouldn't have been triggered in some situations, like a config file for version 23.08 created on 2024-02-29. If the configuration migration script didn't work for you, it's probably too late to fix the conversion script in a way that is actually relevant to users who already upgraded to 24.02.

Internally, printf was never used (QDateTime was always used), the syntax was just printf-like. Re-adding printf-like syntax would add a lot of complexity to filename template parsing. I don't want to support multiple types of syntax, so this probably isn't going to be done.
Comment 2 Jens 2024-03-26 16:37:54 UTC
I also just got bitten by this.
How about the conversion script actually checks for the "%" placeholder in the filename template, and runs based on that result, instead of the config file timestamp?
I think we should still do this, there may be a number of users who have upgraded but haven't used Spectacle yet, and haven't noticed this bug.
Comment 3 gudvinr+kde 2024-03-27 16:24:32 UTC
(In reply to Noah Davis from comment #1)
> I don't want to support multiple types of syntax, so this probably isn't going to be done.

There's no need to, simple regex like "/%[a-z][^a-z]?$/gi" should be good enough for detection with simple lookup table to convert.
Comment 4 Filip 2024-05-14 08:32:19 UTC
*** Bug 486995 has been marked as a duplicate of this bug. ***
Comment 5 Mircea Kitsune 2024-05-14 13:01:14 UTC
Manually setting the filename to "Screenshot_<yyyy><MM><dd>_<hh><mm><ss>" solved the issue for me: I wasn't aware either that it could be customized nor that there was a change to the pattern, my screenshots kept being saved with the name "Screenshot_%Y%M%D_%H%m%S.png" by default.

I see mention of an automatic migration script that should have kicked in, which means that at least for me it failed when upgrading from Plasma 5 to 6 yesterday (Manjaro Linux). Fixing that sounds better than supporting two formats and bloating the system unnecessarily: It actually looks more proper the new way, just that it didn't automatically change.
Comment 6 outfrost 2024-05-15 17:54:15 UTC
The new version just landed in Manjaro stable, and my filename format was not converted. It's very likely that I did change something in Spectacle's config between 28 Feb and the upgrade, but that may well be the case for a lot of users not running KDE neon.

Like others suggest, IMO checking for '%' format specifiers _and_ the lack of new-style specifiers would be a better way to detect the need to convert, rather than just config file date. Perhaps the config file itself should be versioned, to simplify this in the future?
Comment 7 Bug Janitor Service 2024-05-15 20:42:45 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/spectacle/-/merge_requests/366
Comment 8 Noah Davis 2024-05-15 20:44:16 UTC
Git commit a800768c564e2059c5a1fd8fd00dc7afed0d0dc2 by Noah Davis.
Committed on 15/05/2024 at 20:42.
Pushed by ndavis into branch 'master'.

Always convert old placeholder format to new placeholder format when new format is not used

M  +3    -5    kconf_update/spectacle-24.02.0-change_placeholder_format.cpp

https://invent.kde.org/graphics/spectacle/-/commit/a800768c564e2059c5a1fd8fd00dc7afed0d0dc2
Comment 9 Noah Davis 2024-05-15 20:47:51 UTC
Git commit ee70c5027f3a4de4c1762c0975ca8a0461b6f4e3 by Noah Davis.
Committed on 15/05/2024 at 20:47.
Pushed by ndavis into branch 'release/24.05'.

Always convert old placeholder format to new placeholder format when new format is not used
(cherry picked from commit a800768c564e2059c5a1fd8fd00dc7afed0d0dc2)

M  +3    -5    kconf_update/spectacle-24.02.0-change_placeholder_format.cpp

https://invent.kde.org/graphics/spectacle/-/commit/ee70c5027f3a4de4c1762c0975ca8a0461b6f4e3
Comment 10 Fabian Vogt 2024-06-10 06:31:55 UTC
Even with spectacle 24.05 I still had the old placeholders in the config, leading to broken file names.

I assume that's because kconf_update already attempted the update and saved that in kconf_updaterc so it won't try again. You'd have to rename the kconf_update name.
Comment 11 Bug Janitor Service 2024-06-14 15:09:10 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/spectacle/-/merge_requests/377
Comment 12 Noah Davis 2024-06-14 15:10:56 UTC
Git commit 742108af4f0780329afee39907471050d5bb953c by Noah Davis.
Committed on 14/06/2024 at 15:09.
Pushed by ndavis into branch 'master'.

Rename 24.02.0-change_placeholder_format script ID to 24.05.2-change_placeholder_format

Causes the script to trigger again.
FIXED-IN: 24.05.2

M  +3    -1    kconf_update/spectacle.upd

https://invent.kde.org/graphics/spectacle/-/commit/742108af4f0780329afee39907471050d5bb953c
Comment 13 Noah Davis 2024-06-20 06:59:09 UTC
Git commit e0f6ba578539603f1de526b2b5dc78aba7662666 by Noah Davis.
Committed on 20/06/2024 at 06:59.
Pushed by ndavis into branch 'release/24.05'.

Rename 24.02.0-change_placeholder_format script ID to 24.05.2-change_placeholder_format

Causes the script to trigger again.
FIXED-IN: 24.05.2

(cherry picked from commit 742108af4f0780329afee39907471050d5bb953c)

Co-authored-by: Noah Davis <[email protected]>

M  +3    -1    kconf_update/spectacle.upd

https://invent.kde.org/graphics/spectacle/-/commit/e0f6ba578539603f1de526b2b5dc78aba7662666