I’m trying to create a new context menu for dolphin (service-menu) using the tutorial listed here - Creating Dolphin Service Menus | Developer
The custom action I’m trying to define is to scan the directory/file that have been selected with clamdscan along with some options.
Issue: When I select only one file or directory it works as expected. However selecting more than one results in an error as it treats the 2 file files/directory/file+directory as one.
Example: I’ve created a folder within
Downloads called scan-test and inside it there are 2 files
/home/pkg/Downloads/scan-test ├── file1.txt └── file2.txt 0 directories, 2 files
file2.txt and using the service-menu to run a scan I get the following:
/home/pkg/Downloads/scan-test/file2.txt: OK ----------- SCAN SUMMARY ----------- Infected files: 0 Time: 0.000 sec (0 m 0 s) Start Date: 2022:06:26 18:51:37 End Date: 2022:06:26 18:51:37
If I select both the files and try to run the scan using context menu:
client_scan: Failed to determine real filename of /home/pkg/Downloads/scan-test/file1.txt /home/pkg/Downloads/scan-test/file2.txt. Failed to determine real filename of /home/pkg/Downloads/scan-test/file1.txt /home/pkg/Downloads/scan-test/file2.txt. Quarantine of the file may fail if file path contains symlinks. ERROR: Can't access file /home/pkg/Downloads/scan-test/file1.txt /home/pkg/Downloads/scan-test/file2.txt ----------- SCAN SUMMARY ----------- Infected files: 0 Total errors: 1 Time: 0.000 sec (0 m 0 s) Start Date: 2022:06:26 18:53:21 End Date: 2022:06:26 18:53:21
Directly from the command line, I can run a scan for both files at the same time:
pkg ~/Downloads/scan-test: clamdscan --multiscan --fdpass -v file1.txt file2.txt /home/pkg/Downloads/scan-test/file1.txt: OK /home/pkg/Downloads/scan-test/file2.txt: OK ----------- SCAN SUMMARY ----------- Infected files: 0 Time: 0.000 sec (0 m 0 s) Start Date: 2022:06:26 18:54:57 End Date: 2022:06:26 18:54:57 pkg ~/Downloads/scan-test:
This is how my
Exec line in
.desktop looks like:
Exec=konsole --hold -e "clamdscan --multiscan --fdpass -v '%U'"
Based on the site linked above it should work:
The Exec line defines what is run when the user selects the action from the menu. We can put any command we want there. The magic in this line is the “%u” which gets replaced with the URL of the image file before the command is run. If our command can accept more than one file at a time we can use “%U” instead. There are other special %values but %u and %U are probably the most useful for servicemenus.
I’m obviously missing something.
PS: Does anyone know where the
.desktop files for Ark (Compress in Dolphin context menu) is located? Perhaps I can look at that to see how they implement something similar.