This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How do I add a custom right-click menu command in dolphin?

Tags: None
(comma "," separated)
ytsestef
Registered Member
Posts
4
Karma
0
Hello everyone.

I want to extract multi-part .rar files. Ark cannot manage this. So each time I want to extract a multi-part .rar file I have to open a terminal, get to the directory and run the command "unrar -e ". I want to make this command appear when I right-click a .rar file, so that I do the entire procedure faster.

I don't want to use other archiving tools either, because I want to keep KDE4 clean from gnome components and such (in other words I only want to use KDE4 programs and command-line tools). My distro is Kubuntu Intrepid Ibex.

So, how do I add the command (it's called service menu, I think :-S ??)

Last edited by ytsestef on Thu Nov 13, 2008 11:18 pm, edited 1 time in total.
User avatar
neverendingo
Administrator
Posts
2136
Karma
17
OS
Go to ~/.kde4/share/kde4/services/ServiceMenus
There should be some examples already.
Just add a new .desktop file with the right content.


New to KDE Software? - get help from Userbase or ask questions on the Forums
Communicate.
Image
ytsestef
Registered Member
Posts
4
Karma
0
neverendingo wrote:Go to ~/.kde4/share/kde4/services/ServiceMenus
There should be some examples already.
Just add a new .desktop file with the right content.


Thanks for your quick reply!

The directory you mention doesn't exist, however the following does exist:
~/.kde/share/kde4/services/ServiceMenus

Would it be the same? I guess it has to do with the kubuntu...
Secondly, this directory is empty, so I don't know what to include in the new .desktop file.
User avatar
neverendingo
Administrator
Posts
2136
Karma
17
OS
ytsestef wrote:Thanks for your quick reply!

The directory you mention doesn't exist, however the following does exist:
~/.kde/share/kde4/services/ServiceMenus

Would it be the same? I guess it has to do with the kubuntu...
Secondly, this directory is empty, so I don't know what to include in the new .desktop file.


Ok, sry, then you are using intrepid. Yes, the directory is right.
I can give you an example file, it's a desktop file for modifying a file with root privileges:
Code: Select all
[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin,text/*,application/x-desktop
Actions=Editassu

[Desktop Action Editassu]
Name=Edit as Root
Name[it]=Edita come Root
Name[fr]=Editer en tant que Root
Name[es]=Editar como Root
Name[de]=Als root bearbeiten
Icon=kfm
Exec=kdesu "kwrite" "%U"



So you basically see 2 sections. In the first section you need to modify the mimetype to something like this:

Code: Select all
ServiceTypes=KonqPopupMenu/Plugin,application/x-rar


Then give "action" an appropriate name and make sure that the name of the second section corresponds to that.

Now the "names" in the second section are selfexplanatory ;)

And the last one, exec, should be like you mentioned:

Code: Select all
Exec=unrar -e "%U"


Now name that file to .desktop
Not tested, but hope that helps.

Last edited by neverendingo on Sat Nov 01, 2008 2:19 pm, edited 1 time in total.


New to KDE Software? - get help from Userbase or ask questions on the Forums
Communicate.
Image
ytsestef
Registered Member
Posts
4
Karma
0
hey thanks, you're the man!
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
If this thread is solved, please add [SOLVED] to the start of the subject.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
anda_skoa
KDE Developer
Posts
783
Karma
4
OS
[quote='neverendingo' pid='13188' dateline='1225548939']
ytsestef wrote:Thanks for your quick reply!

The directory you mention doesn't exist, however the following does exist:
~/.kde/share/kde4/services/ServiceMenus

Would it be the same? I guess it has to do with the kubuntu...
Secondly, this directory is empty, so I don't know what to include in the new .desktop file.


Ok, sry, then you are using intrepid. Yes, the directory is right.

Just as a note:

the correct path or paths (KDE can search a list of paths for any if its resources) can easily be determined on the command line using the kde4-config tool (or kde-config on KDE3).

In this case (service menus)

% kde4-config --path services

KDE infrastructure and applications use relative paths to such resource paths for almost all the file access (unless it is some user provided file)

Cheers,
_


anda_skoa, proud to be a member of KDE forums since 2008-Oct.
gonenc
Registered Member
Posts
1
Karma
0
already some examples in /usr/share/kde4/services/ServiceMenus (coming with kubuntu 11.04 natty)

tested & working.

I will integrate wipe in right click actions menu in dolphin -->
I will use wipe -rf as command.

create a file named wipe.desktop as user

paste into following lines and save

then copy to /usr/share/kde4/services/ServiceMenus

using dolphin as root (kdesudo -c dolphin) (mimetype: inode/directory) :

wipe.desktop owned by root now content is:

[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KonqPopupMenu/Plugin,inode/directory,all/allfiles
Actions=Wipe;
X-KDE-AuthorizeAction=shell_access

[Desktop Action Wipe]
Name=Wipe
Icon=utilities-terminal
Exec=wipe -rf %F
X-Ubuntu-Gettext-Domain=desktop_kdebase
User avatar
waldelf
Registered Member
Posts
333
Karma
0
OS
http://flexible.xapient.net/?p=461 just some additional information and examples..

glhf


Kubuntu 12.04 x64 | KDE SC 4.8
Nvidia 8800 GTS | Core2Duo E6600 | 4 GB RAM
grekpg
Registered Member
Posts
9
Karma
0
OS
Hy i try add new menu with part of succes
it work but when folder have spaces dont work
i have like that action

[Desktop Action mea_cubicTOerect]
Exec=~/.kde/share/kde4/services/ServiceMenus/grek/grekScrips.sh cubicTOerect "%F"
Name=cubic2equirectangular
MimeType=image/.*;
Icon=story-editor

in ~/.kde/share/kde4/services/ServiceMenus/grek/grekScrips.sh
# i have this : $fileurl='/home/grek/cubi aaaac1/1_0000.tif /home/grek/cubi aaaac1/1_0001.tif /home/grek/cubi aaaac1/1_0002.tif'
#$fileurl is from dolphin right click actions [Desktop Entry] with Exec=~/.kde/share/kde4/services/ServiceMenus/grek/grekScrips.sh cubicTOerect "%F"

#i need add comma between files - they is space separated - is not posiible to change it ?

for fileone in $fileurl
do
InputFileNameList=$InputFileNameList,$fileone
done

-------
and i have
file1 /home/grek/cubi
file2 aaaac1/1_0000.tif
i need of corse
file1 /home/grek/cubi aaaac1/1_0000.tif
file2 /home/grek/cubi aaaac1/1_0001.tif
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Would it be possible for you to post the whole grekScrips.sh file (using [code] tags or a entry on the KDE Pastebin at paste.kde.org)

For spaces, your script likely needs adjusting (KDE programatically passes arguments such as directories around, so spaces, etc cannot be interpreted by a shell).


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
crimsonmane
Registered Member
Posts
1
Karma
0
Here is the function I've defined in /etc/bash.bashrc and the reason I'm here, which is to integrate it into the right-click menu when (and only when) the file is an ISO:
Code: Select all
function miso() {
#! /bin/bash
# Objective: Mount unlimited number of ISO files concurrently.
# Assumption: User wishes to unmount ISO via right-click in Dolphin Places, as with a USB device.
# Assumption: User has ISO files located "wherever" and wants on-the-fly mounting.
# Primary Concern: Excessive folders. Would prefer to have no folders remaining after unmount.
# Solution: Re-use existing folders.

n=0
while :
do
  ((n++))
  if [ ! -f /media/miso$n/* ]
  then
    kdesudo mkdir /media/miso$n 1>/dev/null 2>&1
    sudo mount $1 /media/miso$n -t iso9660 -o loop
    break
  fi
done
}

Notes:
- I've already changed the first sudo line to kdesudo which invokes the graphical password box - it was originally sudo.
- The second sudo cannot be changed to kdesudo because it throws an error "-o is not a valid option", yet it does not alter functionality in terminal; I dont know about once this is converted into the exec portion of a .desktop file (prefered filename: miso.desktop)
- Line #! /bin/bash is present because this function was originally a script stored in its own file.
- Script needs condensed to a run-on (single line) as I'm assuming the exec portion of a .desktop file must be.

Please correct any of my assumptions, and if you are feeling gracious today, provide a snippet to copy/paste into my miso.desktop file. Mostly I'm confused with MimeType; it seems that is the portion which defines what sort of file this appears for while not appearing for other files and I've not located a (good) guide.

Thanks! Hope others find ways to make this useful also!
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
In terms of determining the appropriate mimetype, I suggest running the following command against a ISO file you have. This will return the mimetype you need to add to the *.desktop file.
Code: Select all
file --mime-type /path/to/file.iso


For the command to execute, KDE needs a fully executable script - it has no understanding of bash functions. It will invoke the necessary interpreter as declared by the shebang line however.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
raffairon
Registered Member
Posts
2
Karma
0
OS
Did the directory in where to put the
Code: Select all
.desktop
file changed to
Code: Select all
/home/<username>/.local/share/kservices5/ServiceMenus/
in KDE 5?

I have KDE 5 (on Ubuntu 17.10) and this is what worked for me. Also this topic is the first to show up on Google.

Also, is there no kde5-config? And why do I have kde4-config? It's misleading :P
User avatar
Rog131
Registered Member
Posts
828
Karma
10
raffairon wrote:Did the directory in where to put the
Code: Select all
.desktop
file changed to
Code: Select all
/home/<username>/.local/share/kservices5/ServiceMenus/
in KDE 5?

I have KDE 5 (on Ubuntu 17.10) and this is what worked for me. Also this topic is the first to show up on Google.

Also, is there no kde5-config? And why do I have kde4-config? It's misleading :P



There is no 'KDE 5'. There are:
- KDE Frameworks 5
- Plasma 5
- KDE Applications (year.month.bug_fix_release_number)

There is
Code: Select all
kf5-config


Code: Select all
$ kf5-config --help
Usage: kf5-config [Qt-options] [KDE-options] [options]

A little program to output installation paths
.
.
.


You have the 'kde4-config' because you have a mixed KDE4 / KF5 system.

Same kind of:
- Service Menus Missing - viewtopic.php?f=223&t=128621
- Kubuntu forums: https://www.kubuntuforums.net/showthrea ... post367207


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], rockscient, Yahoo [Bot]