Bug 379956 - Can't open a file with a shell script from digiKam
Summary: Can't open a file with a shell script from digiKam
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Usability-OpenWith (show other bugs)
Version: 5.7.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-17 19:49 UTC by Andrius
Modified: 2022-01-31 07:27 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.8.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrius 2017-05-17 19:49:13 UTC
I have added few bash scripts to the system "Open with" menu.
Normally I select files - right click - "open with" - select the script.
Everything works just fine from my file manager (dolphin) but it is not working 
from digikam.
Any ideas on why is this happening?

https://youtu.be/jT1wo0aKJuo

To reproduce the issue you can create a test script test.sh and make it 
executable:
----beginning of the code---
#!/usr/bin/env bash
for FILE in "$@"; do
echo "File is "$FILE" "
done
----end of the code----

then create test.desktop file, copy it to $HOME/.local/share/applications/ and 
make executable.

---beginning of the code----
[Desktop Entry]
Categories=AudioVideo;Video;
Comment=Test
Exec="/PATH/TO/test.sh" %F
GenericName=Test
Icon=
MimeType=video/x-msvideo;video/quicktime;video/mpeg;video/mp4;
Name=Test
NoDisplay=false
Path=
StartupNotify=true
Terminal=true
TerminalOptions=\s--noclose
Type=Application
Version=1.0
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=
----end of the code----

Then open Dolphin - select few video files - open with - Test
which will work.

Then open digiKam - select few video files - open with - Test
it won't work.
Comment 1 Andrius 2017-05-30 14:37:16 UTC
I think this is fixed. I am able to open images with my script in digikam 5.6.0 appimage
Comment 2 caulier.gilles 2017-05-30 14:44:49 UTC
Good news. Closed...

Gilles Caulier
Comment 3 Andrius 2017-09-12 15:34:58 UTC
I think the issue is back in 5.7.0 pre-release bundle.

I have a script that locates a selected file in a file manager:

#!/usr/bin/env bash

for f in "$@"; do
dbus-send --session --type=method_call    --dest="org.freedesktop.FileManager1"     "/org/freedesktop/FileManager1"     "org.freedesktop.FileManager1.ShowItems" array:string:"file:"${f}""     string:""
done
exit

I can open a file with the script from any application on my Mint MATE but the shortcut does not work from digiKam.

digiKam - select a file - right click - open with - thescript.sh - nothing happens.
If I set Terminal=true in the .desktop file (which I don't need) the terminal window being opened and closed right away.

Is there a solution for this?
Comment 4 Maik Qualmann 2017-09-12 18:06:24 UTC
We use a special function to start programs. It was not possible to use KIO from KF5 under different operating systems. The option to start in the terminal is not supported. Is it possible that you open a terminal in the script?

Maik
Comment 5 Andrius 2017-09-12 18:18:29 UTC
(In reply to Maik Qualmann from comment #4)
> We use a special function to start programs. It was not possible to use KIO
> from KF5 under different operating systems. The option to start in the
> terminal is not supported. Is it possible that you open a terminal in the
> script?
> 
> Maik

Maik,

My plan was to run the script in the background without opening a terminal emulator. 
Are you saying that I have to call the terminal from the script, run the command  and close the terminal ?
Comment 6 Andrius 2017-09-17 14:34:07 UTC
Maik,

I played a bit more with opening files from digikam with my scripts on a non KDE machine and here is what I found so far:

- for background scripts (scripts that do not need a terminal window): right click - open with - /path/to/script.sh works just fine
- if you want to open a script in a terminal: right click - open with - xterm -e /path/to/script.sh works just fine (make sure xterm is installed in your system)
- weird thing that the same command but with mate-terminal or gnome-terminal does not work. No arguments (%F) being passed to the script. Not sure if it is digikam related or the terminal related issue. Same command from Caja(Nautilus) works just fine.
Comment 7 Maik Qualmann 2017-09-18 19:58:14 UTC
Git commit 0b6ef6e4e4d6adba5b4efe80bf4be3cc70b2ccf0 by Maik Qualmann.
Committed on 18/09/2017 at 19:57.
Pushed by mqualmann into branch 'master'.

add terminal support for runFiles() only for Linux systems
- first search for konsole from KF5 if not exist search for xterm
- full terminal options support
FIXED-IN: 5.8.0

M  +1    -1    app/utils/contextmenuhelper.cpp
M  +39   -7    libs/threadimageio/dfileoperations.cpp
M  +2    -3    libs/threadimageio/dfileoperations.h
M  +1    -1    utilities/imageeditor/editor/editorwindow.cpp
M  +1    -1    utilities/importui/widgets/importcontextmenu.cpp

https://commits.kde.org/digikam/0b6ef6e4e4d6adba5b4efe80bf4be3cc70b2ccf0