简体   繁体   English

KDE Dolphin服务菜单以打印PDF

[英]KDE Dolphin Service Menu to Print PDFs

I tried to create a service menu so that I can print pdf files directly from dolphin's context menu. 我试图创建一个服务菜单,以便可以直接从海豚的上下文菜单中打印pdf文件。

Here's the print-pdf.desktop file: 这是print-pdf.desktop文件:

[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. 但是,可以预料的是,所有pdf文件都将立即打印,而不仅仅是选定的文件。 I tried using '$1' as well, but that did nothing. 我也尝试使用'$ 1',但这没做。

Is there a way to tell dolphin to process only selected files? 有没有办法告诉海豚处理选定的文件?

Following the .desktop spec , we can use %f to pass in a single file as an argument ( %D is deprecated). 遵循.desktop规范 ,我们可以使用%f将单个文件作为参数传递(已弃用%D )。 Using %f has the additional benefit that we do not need to loop over the selected files ourselves. 使用%f的另一个好处是我们不需要自己遍历所选文件。

So to make your service menu work, replace the Exec=... line with 因此,要使服务菜单正常工作,请将Exec=...替换为

Exec=lp %f

Furthermore the .desktop file has to be placed in 此外,必须将.desktop文件放置在

~/.local/share/kservices5/ServiceMenus/

to be recognised by Dolphin. 被海豚认可。 I wish this was documented somewhere. 我希望这个记录在某处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM