Dolphin service-menu help

That returns an error in Dolphin itself:

Syntax error in command konsole --hold -e "clamdscan --multiscan --fdpass -v \"%U\"" coming from

It’s not me who truncated the error, it shows up like that.

What about changing the .desktop entries to something like… :arrow_down:

Exec=clamdscan --multiscan --fdpass -v "%U"  ; echo ; read -n1 -p "Press any key to close the window."

Adding this and opening the service-menu in Dolphin, does not show anything. I know it says Terminal=true but think it may be applicable for launching applications.

The original problem with %U is that adding the " makes it into a string and now when using that as an argument it returns a string and clamd considers the whole thing to be one file rather than multiple separated by spaces. But for files with spaces, that’s another problem altogether.

//EDIT: It may actually be working in the background without the terminal showing up. I’ll do this for a large folder and check.

That’s what I was thinking too. So the problem lies with clamdscan, rather than with Konsole or Dolphin.

preface a command that returns a new-line separated list of filenames

and feed that to %U

but I would not begin to know how …

I’m just guessing - and have zero experience.

Have you had a look at what and how “meld” does do it?

It does have to deal with things like this … all the time.

1 Like

Something like… :arrow_down:

Exec=konsole --hold -e 'for fn in "%U" ; do clamdscan --fdpass -v "${fn}" ; done'

… maybe? :thinking:

Note: If this works, then it’ll take up more time than passing a list of filenames to clamdscan with the --multiscan option, because this is an iteration that will call clamdscan for every individual file.

Finally got it working after finding the freedesktop .desktop specifications site:

%U: A list of URLs. Each URL is passed as a separate argument to the executable program. Local files may either be passed as file: URLs or as file path.

While it does seem to indicate that this can be used for local files, based on playing with it in the last hours this is true if and only if one of the (file | directory) selections does not contain a space. This is because the default separator for multiple file/directory/URL path is space with no way to change it.

However, using %F does not have this drawback.

%F: A list of files. Use for apps that can open several local files at once. Each file is passed as a separate argument to the executable program.

I ended up using this and it works as expected:

Exec=konsole --hold -e clamdscan --multiscan --fdpass -v %F
/home/pkg/Downloads/scan-test/file1.txt: OK
/home/pkg/Downloads/scan-test/file2.txt: OK
/home/pkg/Downloads/scan-test/Text File.txt: OK

----------- SCAN SUMMARY -----------
Infected files: 0
Time: 0.000 sec (0 m 0 s)
Start Date: 2022:06:26 22:22:29
End Date:   2022:06:26 22:22:29

@Aragorn : Yep, I was just about to give up and use bash or python and add that to the Exec line to handle logic.

Thanks everyone for help, I got a bunch of ideas and was able to play with it all.

My final service-menu for those interested. It has to be saved to ~/.local/share/kio/servicemenus/ and adds a new context-menu on right-click of one or multiple files/folders called Scan File/Directory:

[Desktop Entry]

[Desktop Action clamdScan]
Name=Scan File/Directory
Exec=konsole --hold -e clamdscan --multiscan --fdpass -v %F


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.