Update 11 Feb 09: My CMS mangles the quotes below into smart quotes, so convert those back to straight quotes. Also, the ps2epsi that comes with Ubuntu Hardy 8.04 is broken, so replace it with the latest version.
Update 6 Feb 09: I switched to KDE 4.2 and the menus are a bit different. I haven’t found a reference yet but I haven’t really looked either. The file now goes in ~/.kde/share/kde4/services/ServiceMenus. Here’s the body:
[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=application/postscript
Actions=ToEPSI;[Desktop Action ToEPSI]
Name=To EPSI
Icon=previewer
Exec=/bin/sh -c “cd `dirname ‘%f’`; ps2epsi ‘%f’”
Following up on the earlier blog post on making an SVN service menu, here’s how to make one to convert .ps (postscript) files into .epsi (encapsulated postscript files with an embedded preview image). This conversion also sets the bounding box correctly, so when I print to a .ps file from a normal app that formats it for letter paper, ps2epsi will shrink it down to minimal size.
Here’s the service menu code. This was only tricky because the script does not run in the current directory, but in your home directory (why?), so you have to either construct anoutput filename with the right directory on it, or cd to the current directory.
Tutorial on service menus in kde
Create a file in this location:
/home/elvis/.kde/share/apps/konqueror/servicemenus/ps2epsi.desktop
Here are the file contents:
[Desktop Entry]
ServiceTypes=application/postscript
Actions=ToEPSI[Desktop Action ToEPSI]
Name=To EPSI
#Exec=ps2epsi ‘%f’ `dirname %f`/`basename %f`.epsi
Exec=/bin/sh -c “cd `dirname ‘%f’`; ps2epsi ‘%f’”