Bug 471492 - Scripts in context menu
Summary: Scripts in context menu
Status: REPORTED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-Bqm-Script (show other bugs)
Version: 8.2.0
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-27 07:41 UTC by
Modified: 2023-07-30 19:04 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description 2023-06-27 07:41:08 UTC
It would be useful if some processes could be run for bunch of files instead of using editor, separate file manager or terminal. I currently use nautilus scripts and terminal to do some processes, but it would be good to be able to run them right-clicking directly from digikam. 

For example *convert* could be used to easily reduce filesize for bunch of unimportant files which you still want to keep, or *ffmpeg* to trim overlong audio/video files... and some more basic editing.

Or is this possible already somewhere in KDE file manager settings digikam is built on?
Comment 1 Maik Qualmann 2023-06-27 08:11:28 UTC
The BQM can run scripts, it is possible to save BQM workflows and thus also the scripts created.
It is also possible to create *.desktop files under KDE so that they can then be selected via digiKam "Open with...".

Maik
Comment 2 2023-06-27 15:18:21 UTC
Found at least this discussion https://bugs.kde.org/show_bug.cgi?id=393382 Have to take a look how it works.

*** This bug has been marked as a duplicate of bug 393382 ***
Comment 3 2023-06-27 19:06:45 UTC
I think BCQ seems too difficult to use frequently (unpractical) if after selection I have new window opened and lots of buttons there. 

I would like to be able to create custom scripts and have them available in context menu to directly access from album and other views. 

I would be ok if the scripts could be maintained like nautilus actions just by adding scripts to specific folder. Can this be achieved with *.desktop-files?
Comment 4 2023-06-27 19:07:22 UTC
*BQM*
Comment 5 2023-06-27 19:09:12 UTC
Ideally there could be option for popup to make few customizations before running script, but that's not needed in all cases.
Comment 6 Maik Qualmann 2023-06-27 20:41:56 UTC
The BQM is not difficult to use once you get the hang of it. You can create and save workflows. The workflows can be loaded with just one click from a list and all settings are restored. In addition, the BQM ensures that the metadata in the DB is up-to-date after image processing.

Maik
Comment 7 2023-06-27 21:19:37 UTC
Last is valid point. 

I just did a test with 80 files using workflows from early tests. Process is bit more sluggish than I'd hope but quite ok. One thing I'm worried is behavior tab where you can possibly override something you could say definitely in the script, particularly overwrite/rename, but it appears that saving workflow saves this setting too. These are tasks that are repeated countless times and I'm wondering if it could be possible that this setting hidden could cause problems, but possibly not.

I have to do further testing.

However I suggest that these workflows then could be added to right click context menu for quick access and instantly run from there? Enabling this 'quick context menu access' could possibly be setting to enable it in "edit workflow" window?

But thanks, I think this already helped a lot.
Comment 8 2023-06-27 22:43:04 UTC
Also I find it very weird and likely cause problems, that if I leave picture in queue, close and restart digikam, it's still there waiting... Processing numerous pictures easily hide unwanted files to be processed, I've possibly already done that.

It would be useful to have option to just select what you want and without fuzz have them processed with guaranteed, predefined and repeatable way.
Comment 9 2023-07-02 18:40:32 UTC
So the feature already is pretty much already there, but it would need to be more easily accessible. Two simple processes would be needed:

A) By simple checkbox in workflow settings adds any workflow available in right-click context menu while file browsing (or to make things easier they could all be available)
B) Doing file selection and choosing workflow from context menu would instantly (using already existing feature) i) create queue ii) run selected workflow v) remove queue

I for example often need temporary smaller versions of pictures (email attachments etc.) and creating them could still be little easier. And there's many other uses. Especially when dealing with just single files at time manually creating and handling queues seems unnecessary while existing procedure is needed and important in creating workflows, but I would leave current separate worktable mainly for management and prefer quicker alternative for using them if they are needed repeatedly.
Comment 10 2023-07-15 10:10:17 UTC
For repeated tasks there's just too much unnecessary clicking when you have to use separate window, including selecting background window, switching control panel tabs and emptying the queue. (You can't even click-by-click remove single items from queue in cases that would be faster, but you have to select next file after deleting previous...) To some extent would be helpful even if the queue could be set to automatically emptied after running.

However context menu integration would be the easiest way to handle this kind of extra automation which wouldn't need to be included to actual tool/manager itself. I'm quite sure this feature could be implemented with rather small amount of code calling existing methods the way that they're run together without further interaction during the whole process after selecting items and executing command from context menu.

i) transmit list of selected items to this pipe
ii) apply desired command to them
iii) reset feature (remove queue and possibly command it it's left preset)
iv) end

It's already possible to close the bqm window during process and see the progress bar at main window status bar, so no window need to be opened at all. So part of the problem is that whatever was done is left to bqm if reopened and causes hazzle to run even same commands to different files, and running them could have easier method/alternative in the first place.

Tool itself is very nice, including how database is maintained both in replacing and creating new files. I've yet to experiment running multiple commands at once.
Comment 11 2023-07-23 09:53:41 UTC
I was able to find source code locations

digikam / core / app / items / utils / contextmenuhelper.h/cpp
digikam / core / dplugins / bqm

First supposedly has enough examples to create proper context menu item. 

Latter possibly has needed functionality i) to list all workflows* in context menu and then ii) method to call to execute for selected items? 

*However I think some of these commands could be even built in (not user scripts) so I think possibly all precoded functionality ("plugins") could be made (safe way) directly available via context menu.

I could possibly try to figure out how to get either of this (user sripts and/or plugins added directly to context menu) done in C++.
Comment 12 2023-07-29 18:36:37 UTC
Is it possible to run BQM only for image files? I've tried to run it for sound and video, but for example separating audio from video with:

ffmpeg -i $INPUT -vn -c:a copy $OUTPUT.m4a

gives

ORIGINALFILENAME ...Failed to process item...
ORIGINALFILENAME ...Failed to save item...

There actually seems to be many places where to adjust filenames: i) Queue settings -> Behavior, ii) Tool settings -> Output file type,iii) and possibly within code too??

#2) I tried to install digikam source code via kdesrc-build but some dependency couldn't be installed (and installer for some reason tries to use home directory where I don't have enough space). Completely different guide at https://www.digikam.org/api/ appears to have some presuppositions I don't understand. There's also another plugin I would like to see if it could be improved.
Comment 13 2023-07-30 19:04:45 UTC
Converted file was actually found from directory as

BatchTool-smFwpk-f6181d32.digikamtempfile.MTS.m4a

but for some reason doesn't appear at digikam. If I manually rename it, it will show after refreshing.

If I change code to

ffmpeg -i $INPUT -vn -c:a copy $INPUT.m4a

file has correct name but same error messages appear and view has to manually refreshed to make the file show. Also database is not updated (tags and locations are not given to new files).