Reputation: 105
I tried to create a service menu so that I can print pdf files directly from dolphin's context menu.
Here's the print-pdf.desktop file:
[Desktop Action print-pdf]
Exec=/home/me/.kde/share/kde4/services/print-pdf.sh %D %U
Icon=stock_print
Name=Print PDF
[Desktop Entry]
Actions=print-pdf
Icon=print
MimeType=application/pdf
ServiceTypes=KonqPopupMenu/Plugin
Type=Service
X-KDE-Priority=TopLevel
And here's the script it's supposed to execute:
#! /bin/bash
for FILE in *.pdf;
do lp $FILE;
done
However, as to be expected, all pdf files are printing at once instead of only those selected. I tried using '$1' as well, but that did nothing.
Is there a way to tell dolphin to process only selected files?
Upvotes: 3
Views: 1242
Reputation: 819
Following the .desktop spec, we can use %f
to pass in a single file as an argument (%D
is deprecated).
Using %f
has the additional benefit that we do not need to loop over the selected files ourselves.
So to make your service menu work, replace the Exec=...
line with
Exec=lp %f
Furthermore the .desktop file has to be placed in
~/.local/share/kservices5/ServiceMenus/
to be recognised by Dolphin. I wish this was documented somewhere.
Upvotes: 3