Adding MD5Sum to KDE GUI Right-Click Menu

KDEKDE is a great desktop environment and its killer feature has always been the great level of customization that you can perform. In this post I look at adding support for MD5, SHA256 and other file checksum operations to the right-click context menu. This will allow you to do an MD5sum or SHA256sum of ISO images or other files right from within the GUI.

Right-Click Menu

The menu we are going to be customizing is displayed when you right click on a file or directory anywhere in KDE or Dolphin:

KDE Right Click Menu

KDE Right Click Menu

To add your own entries to the Actions sub-menu you have to locate your service menus directory under your home directory by running the following command:

kf5-config --path services

In most cases it is ~/.local/share/kservices5/.

If that directory doesn’t exist then create it as well as a sub-directory in it called “ServiceMenus”. Then create a text file with the .desktop extension in the ServiceMenus sub-directory. This file will contain the custom sub-menu we will be creating.

The file will begin with the following:

[Desktop Entry]
X-KDE-Submenu=File Checksum

[Desktop Entry] is the name of the section. .desktop files are divided into multiple sections.

Type is set to service to distinguish it from an application shortcut. Then we specify that it is a menu in the X-KDE-ServiceTypes line. If X-KDE-ServiceTypes does not work for you just type ServiceTypes instead.

MimeType will determine whether this menu will be displayed for a particular file or directory. application/octet-stream means that this menu will be displayed for all files but not for any directories. You can’t md5sum a directory so we restrict ourselves to files.

The Actions line contains the names of multiple action sections which we will cover later.

In the next two lines we specify that the menu should only show for those with shell access privileges and that this is a sub-menu labeled “File Checksum”. We want to add support for multiple file checksum programs so we group them under a sub-sub-menu.

Actions Sections

The actions sections are the actual menu commands. Let’s look at one of the action sections:

[Desktop Action md5sumfile]
Exec=konsole --hold -e md5sum %F

In the very first line we have the action name md5sumfile. This is the same name we used to refer to the action in the Actions entry under the Desktop section before.

The “Name” line is actually the human friendly label for this command. It is what will appear in the menu.

Icon contains the name of the icon file excluding extension. You can find all the icons you can use in your /usr/share/icons/ directory.

Exec is the command to be executed when menu item is selected. In this case we are running konsole terminal app with:

  • –hold : Keep the window open after the command has executed so that we can see the output.
  • -e : The command to execute. In this case md5sum with %F as argument. %F will be replaced with the paths to selected files.

If your command can only take one argument you can specify %f (lower case f). The full list of possible arguments is given here.

The other action sections for sha256sum and sha1sum are built along the same lines.

You can see a screenshot of the menu below:

File Checksum KDE Right Click Menu

File Checksum KDE Right Click Menu

Full documentation on service menus can be found here.

Download the full .desktop file with support for MD5, SHA256 and SHA1 file checksums:

One thought on “Adding MD5Sum to KDE GUI Right-Click Menu

Leave a Reply

Your email address will not be published. Required fields are marked *