Please explain the Exec= lines in this ServiceMenu provides a submenu with several actions:

KDE service menu available under the Dolphin contextual menu, which adds the ability to copy in the clipboard the details of the selected file:

  • Full filename
  • Path only
  • Filename only
  • Filename without extension
  • md5 checksum
  • sha256 checksum
  • sha512 checksum
  • mime type
  • file type
  • file size (bytes format)
  • file size (human-readable format)
  • file permissions (octal format)
  • file permissions (human-readable format)
  • group id
  • group name
  • file user id
  • file user name
  • last access
  • last modification
  • mount point

All of these have Exec= lines that I don’t understand. For example, “Desktop Action copy_filename_name_noext” has this Exec= line (currently line #65 in the link above):

Exec=exe=command -v qdbus-qt5 || command -v qdbus;x=%n;$exe org.kde.klipper /klipper setClipboardContents "${x%.*}"

  • I haven’t seen Exec=exe before
  • What does command -v mean in command -v qdbus-qt5 || command -v qdbus?
  • What is $exe?
  • According to The Exec key, %n is deprecated and there’s no description of its role

(I’m guessing x=%n and ${x%.*} relate to parameter expansion.)

You lost some characters during copy.

Exec=exe=`command -v qdbus-qt5 || command -v qdbus`;x=%n;$exe org.kde.klipper /klipper setClipboardContents "${x%.*}"

There are several commands separated by ; in a single line.


exe=`command -v qdbus-qt5 || command -v qdbus`

means asign output of command -v qdbus-qt5 || command -v qdbus to exe variable.


asign content of n variable to x variable
Something I am not sure right now.

$exe org.kde.klipper /klipper setClipboardContents "${x%.*}"

Here $exe is translated to just a content of exe variable which is most likely some command.

The important part here is from man command:

       -v        Write a string to standard output that indicates the pathname or command that will be used by  the  shell,  in  the
                 current shell execution environment (see Section 2.12, Shell Execution Environment), to invoke command_name, but do
                 not invoke command_name.

                  *  Utilities, regular built-in utilities, command_names including a <slash> character, and any  implementation-de‐
                     fined functions that are found using the PATH variable (as described in Section, Command Search and Ex‐
                     ecution), shall be written as absolute pathnames.

                  *  Shell functions, special built-in utilities, regular built-in utilities not associated with a PATH search,  and
                     shell reserved words shall be written as just their names.

                  *  An alias shall be written as a command line that represents its alias definition.

                  *  Otherwise, no output shall be written and the exit status shall reflect that the name was not found.

So $exe is either qdbus-qt5 or qdbus if the qt5 version failed during the first command execution.
Correction: /usr/bin/qdbus since command returns full path to the executable.

So you can look at it like:

qdbus-qt5 org.kde.klipper /klipper setClipboardContents "${x%.*}"

Does that make more sense? I am not entirely sure what is the purpose of x=%n but I would probably have to think about it more.


Thanks for looking into this!

I fiddled around and reduced the code to:
Exec=x=%n;qdbus-qt5 org.kde.klipper /klipper setClipboardContents "${x%.*}"

The x=%n is for the subsequent parameter expansion, "${x%.*}".

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.