I'll preface this with; I was tired of double clicking a newly written script and having it open up in kwrite, rather then executing as planned... leading to a short pause while I opened a terminal to chmod the misbehaver. After all the trouble I thought I'd share my findings... even though I'm pretty sure most of you use Gnome
As with KDE 3.x the menu item consist of two parts, one to define it's location and what will activate it, the other to define what it will do. Both parts are fairly straight forward, but I'll explain the variable parts in case it's the first time you've looked at one.
Code: Select all
[Desktop Entry]
Type=Service
Encoding=UTF-8
X-KDE-ServiceTypes=KonqPopupMenu/Plugin
MimeType=text/plain;text/x-python;application/x-sh
Name=Chmod
Actions=MakeExe
[Desktop Action MakeExe]
Name=Make File Executable
Exec=chmod +x %F
Icon=kformula
Code: Select all
X-KDE-ServiceTypes=KonqPopupMenu/Plugin
Code: Select all
MimeType=
Code: Select all
/etc/mime.types
You could add function for all file types with
Code: Select all
application/octet-string
Code: Select all
text/*
Code: Select all
image/*
Code: Select all
Actions=
Code: Select all
[Desktop Actions MakeExe]
Code: Select all
Actions=
Code: Select all
Name=
Code: Select all
Exec=
Code: Select all
%f A single file name
%F Multiple selected files, use this for programs that know how to act on multiple files simultaneously.
%u A single URL
%U Multiple URLs
%d A single directory containing the file represented by %f
%D A list of the same directory containing an entry for all selected files representing %F
%n filename without an associated path
%N Multiple files without paths
%k A file represented by a URL
Code: Select all
Icon=
For single variable commands like this you don't need any associated shell script to install the menu item, simple copy them into KDEs service directory... but where might that be?
run the following code to locate your service directory
Code: Select all
kde4-config --path services
You may have to restart x for your menu to take effect... but I didn't experience that.
It should be noted that there are plenty of service menu add-ons available from
Code: Select all
http://kde-look.org/
Original form of the code (for KDE 3.x) can be found in O'Reilly's Linux Desktop Hacks; #40, modifications credited to a few hours on Google (you might be surprised how much misinformation is out there), and a few hours in bash working out the kinks