-
DOLPHIN > créer des actions personnalisées (service menus) par clic-droit
- Create the folder ~/.local/share/kservices5
- Create the folder ~/.local/share/kservices5/ServiceMenus
- In ~/.local/share/kservices5/ServiceMenus create a plain text file called move.desktop
- Dolphin file manager (obviously).
- kdesu – if it’s not installed by default, install it.
- ~/.local/share/kservices5/ServiceMenus/
- /usr/share/kservices5/ServiceMenus/
- Make sure that your distribution doesn’t use a customized path.
- Create the path.
Tous les fichiers pour le clic droit se trouvent ici :
/usr/share/kde4/services/ServiceMenus/amarok_append.desktop // tous les utlisateurs ~/.kde/share/kde4/services/ServiceMenus/monaction.desktop // pour l'utilisateur toto
Le fichier
.desktop:[Desktop Entry] Type=Service ServiceTypes=KonqPopupMenu/Plugin,inode/directory,all/allfiles Actions=bonjour; X-KDE-Submenu=MON_MENU [Desktop Action bonjour] Name=Mon script Icon=cab_view Exec=/chemin/vers/script.py %U
NOMENCLATURE DU FICHIER .desktop
[Desktop Entry]
X-KDE-Priority=TopLevel-> si on veut directement sur le menu (pas dans Actions)X-KDE-Submenu=TOTO-> si on veut créer un sous-menu appelé TOTOLIENS
Liste de fichiers desktop
https://store.kde.org/browse/cat/102/order/latest/
—
the mime type would be
MimeType=all/all
An overview over all files can be found under
/usr/share/mime/
As you can see, its always in the form of XXX/YYY. XXX stands for of the folders inside /usr/share/mime and YYY should be a name of the files inside that folder (without the extension).
—
8You can create a Service Menu to do what you want.
Paste the following content into move.desktop
[Desktop Action move-file] Exec=/usr/lib/x86_64-linux-gnu/libexec/kf5/kdesu mv "%U" /usr/share/applications Name=Move file Icon=document-send [Desktop Entry] Actions=move-file MimeType=application/x-desktop; ServiceTypes=KonqPopupMenu/Plugin Type=Service X-KDE-Priority=TopLevel
The use of
MimeType=application/x-desktop;
ensures that this context menu entry will be seen only when the target file is a .desktop file.This is an image of Dolphin’s context menu before creating the service menu:
In the following screenshot taken after creating the service menu you’ll see an additional entry, Move file:
Clicking on Move file will prompt you for your password because you want to move a file into /usr/share/applications.
After providing your password, the selected file will be moved to /usr/share/applications:
Note that the owner isn’t the same as .desktop files already there. You’ll need to fix that however you choose:
In case you need to change ownership/permissions, you could modify the
Exec=
line like this (to change ownership):Exec=printf %U | xsel -b -i && /usr/lib/x86_64-linux-gnu/libexec/kf5/kdesu mv "%U" /usr/share/applications && cd /usr/share/applications && /usr/lib/x86_64-linux-gnu/libexec/kf5/kdesu chown root:root $( basename $(xsel -b -o) )
The additional steps involve using printf and xsel to put the path of the file into the clipboard and then using basename to strip off everything but the filename. Of course, you’ll need
kdesu
again! I don’t know if there’s a shorter way!—
How To: Add “Open As Root” Entry Manually To KDE’s Dolphin File Manager?
Add custom action that allows you to open a Dolphin file manager iteration with root privileges from within a graphic interface. Linux and in particular KDE are so customizable that you’ll have hard time to find a feature that you like which isn’t already present or easily add-able as an extension. However, on the rare
Updated Aug 29, 2017How To’sWritten by LironLinux and in particular KDE are so customizable that you’ll have hard time to find a feature that you like which isn’t already present or easily add-able as an extension.
However, on the rare occasions where the given supply isn’t quite to your satisfaction, there’s always the good old method of paving your own road, so to speak.
In the following, I shall demonstrate how to create a custom action (as per Xfce) that will let you launch a root-privileged Dolphin from within a non-privileged one.
Note that although I’m using it to create a “Open As Root” entry in the right-click context menu, the same method can apply to any other custom action you may desire.Requirements
[Update 15/05/2017]: users with KDE Applications 17.04 and above may not be able to launch Dolphin as root anymore, please see: KDE Plasma Canceling “Run As Root” Is Now Taking Effect – for more details. (but before you do, please read the line below)
[Update 27/08/2017]: The above mentioned limit can be bypassed, read here how.
Create The Entry
In KDE 5 there are basically two places where Plasma, your desktop environment, will “look” for custom actions by default:
The difference is that the first one will only apply to a specific user whereas the latter will apply to all users.
Note: if any of the above paths does not exist on your system –
Now, navigate into the location you wish to create the custom action in. (Remember, use location #1 for only your user and #2 if you want the custom action to be available for evryone that uses the system!)
Create a text file and name it an easily to remember name with the suffix “.desktop”, like this: root_dolphin.desktop.
Copy paste the following text inside it:
[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KonqPopupMenu/Plugin
MimeType=inode/directory;
Actions=openRootDolphinHere;
X-KDE-AuthorizeAction=shell_access[Desktop Action openRootDolphinHere]
Name=Open Root Dolphin Here
TryExec=kdesu
Exec=kdesu dolphin %U
Icon=folder-redSave and close the file.
Restart Dolphin, right click and check whether your newly created entry is inside Actions.
If not, click Control on the top bar > Configure Dolphin… > Services > check Open Root Dolphin Here then click OK.
Right click, and there you have it inside Actions item.