Skip to content

fabiomux/kde-servicemenus

Repository files navigation

KDE Service Menus

KDE service menus, or Dolphin service menus, are mainly INI files implementing the recommendations of the Freedesktop Desktop Entry Specification, and provide a method to embed in the contextual menu of KDE applications dedicated to file management (like Dolphin, Krusader, Konqueror, and KFind), shortcuts that recall an application that might come in handy to manipulate the selected files.

With some extra effort instead of a single command, a complete script can be included within these add-ons, so over time, I wrote a bunch of them to solve or speed up a wide range of problems, and here I decided to publish those of common interest.

The main goal is to provide decent quality addons, all of them are packed following these principles:

  • Essential bundle: no extra script besides the installer is bundled, all the commands go in the desktop file and the final size shouldn't exceed the order of the tens Kbytes, indeed the files included in the archive are:
    • The installer that is in charge of installing and uninstalling the service;
    • The README file for documentation;
    • A simple Makefile for those who don't like to read the README file;
    • The LICENSE file;
    • The desktop file containing the service.
  • Different levels of documentation and reference are also very important:
    • In the desktop file itself;
    • In the README file;
    • In the KDE-store page;
    • In the Blog page.
  • POSIX compatibility to run flawlessly on the two basic shells: Bash and Dash;
  • The best integration level as possible.

The last point requires some more explanation. Until these add-ons run commands without interaction it is easy to create a service menu perfectly integrated with the environment: the standard provides a method to customize the menu labels for each language just specifying its code between square brackets.

Unfortunately, when speaking about interactions through Kdialog's dialogs, there is not a simple workaround to output the request in the current language without complicating the code structure, but that's quite normal, these add-ons are not intended to implement a lot of commands in a single line.

Also, moving the entire code in an external script wouldn't solve the problem, but would only move it outside the desktop file.

As an alternative, I found it easier to create a system to keep the commands separated from the localization strings, as usually happens for similar contexts in other programming languages, then creating a compiler that would build different packages for each localization.

This is the best way I found to overcome that small but annoying problem, and now every service can be fully localized and provided as a separated package directly in the KDE-Store!

Last but not least, speaking about integration, it also important for me to be able to install the services within the three KDE environments:s KDE 4 (for legacy), Plasma 5, and the new Plasma 6.

The available services

My personal KDE service menus collection includes the following scripts:

  • Compare with Kompare: Cache and retrieve the file to compare with the selected one, using the clipboard area or a cache file;
  • Compose with Betterbird: compose a new email with the Betterbird email client using the selected files as attachments;
  • Compose with Betterbird (Flatpak edition): compose a new email with the Betterbird email client using the selected files as attachments (Flatpak edition);
  • Compose with Thunderbird: compose a new email with Thunderbird email client using the selected files as attachments;
  • Compose with Thunderbird (Flatpak edition): compose a new email with Thunderbird email client using the selected files as attachments (Flatpak edition);
  • Copy Filelist to Klipper: copy the result of several types of finding, accomplished through the find command, in the clipboard area using the Klipper D-Bus service;
  • Copy to Klipper: copy the selected filename name, or parts of it, in the clipboard area using the Klipper D-Bus service;
  • Download with youtube-dl here: download a file in the current folder using the youtube-dl command line tool;
  • Download with yt-dlp here: download a file in the current folder using the yt-dlp command line tool;
  • Open Konsole Here: open the selected path in the first or last Konsole window, current or new session;
  • Open with gVIM: displays all the selected files in different gVIM tabs instead of opening them in hidden buffers;
  • Open Yakuake Here: open the selected path in the current or new Yakuake's session, within the current terminal with or without splitting it horizontally or vertically;
  • Scan with ClamAV: scan the current directory or selected folder/file with ClamAV using either Yakuake or Konsole;
  • SQLite Tools: useful commands to perform on SQLite database files.

Install

There are several ways to install the service menus listed in this repository. The best option is always using the KDE store service from Dolphin or Discover, but in case something goes wrong, one of the method below might come in handy for debugging purposes.

From Dolphin

All of them are available at the KDE store and, at the same time, in the twin websites (Opendesktop, Pling), that way the installation can be easily performed from the settings interface:

Settings > Services > Download new Services

Just fill up the text box with the service name, and once found, install it using the install button.

From the same interface can uninstall the service menu as well.

From the tar archive

Once downloaded, the archive from the KDE store, or one of the other twin websites can make use of the Makefile included or install the archive using the servicemenuinstaller utility.

Using the Makefile

After extracting the archive:

$ tar -xvf <archive-name.tgz>

And enter the folder:

$ cd <project_folder>

To install the service menu:

$ make install

To remove the service:

$ make uninstall

Using servicemenuinstaller

It is a Dolphin utility that automatically installs the archives downloaded from the KDE store:

$ servicemenuinstaller install <archive-name.tgz>

To uninstall the service:

$ servicemenuinstaller uninstall <archive-name.tgz>

From the GitHub repository

After cloning the repository:

$ git clone https://github.com/fabiomux/kde-servicemenus.git

Enter the project folder:

$ cd kde-servicemenus

Build the archive for the wanted project replacing project_name with the related folder:

$ make <project_name>

Install it using the Dolphin utility:

$ servicemenuinstaller install <archive-name.tgz>

You can use the same archive to uninstall the service if not needed:

$ servicemenuinstaller uninstall <archive-name.tgz>

Contributing

Besides reporting bugs or asking for new features on the issues page, another way to lend your help to the project is translating the strings used within the service menus.

To make the services fully compliant to a particular language, I created a system to embed the strings directly within the exec line and generate a different package for each one.

The translated strings are available under the path of this repo:

_locale/<service_folder>/<language_code>.yaml

The placeholders are quite self-explanatory, all the translations are based on the en.yaml file and respect the YAML format.

Get Help

More info is available at: