feh or eog on the chosen images. The process involves writing an XML descriptor, placing it in the correct configuration directory, and restarting the file manager to apply changes.
Understanding the Transition from Nemo to Dolphin
Nemo uses a specific mechanism called "Actions" defined in INI files located in ~/.local/share/nemo/actions/. Dolphin, being part of the KDE ecosystem, uses a different system based on XML files placed in ~/.local/share/kio/servicemenus/. While both systems allow right-click context menu integration, their syntax and execution environments differ significantly. Migrating a script requires translating the Nemo INI structure into a Dolphin servicemenu XML format.
The core goal is to maintain the functionality: when a user selects one or more image files in Dolphin, they should be able to right-click, select a custom menu item (e.g., "Show Slideshow"), and have those files displayed in a full-screen or windowed slideshow mode. We assume the target system is a Linux distribution using KDE Plasma or a desktop environment with Dolphin installed, such as Kubuntu or openSUSE.
Creating the Custom Action XML File
The first step is to create a new XML file that describes the action. You can name this file something descriptive, such as slideshow.desktop, although the extension .desktop is standard for these service menus. Open your preferred text editor and create a new file.
The XML file must adhere to the Desktop Entry Specification. Below is the essential structure for a slideshow action:
[Desktop Entry]
Type=Service
MimeType=image/*;video/*;application/pdf;
Actions=Slideshow;
[Desktop Action Slideshow]
Name=Show Slideshow
Exec=feh -F -r %F
Icon=media-playback-start
Terminal=false
Let's break down the critical components of this configuration:
- Type=Service: This tells the system that this file is a service menu entry, not a regular application launcher.
- MimeType: This field determines when the action appears in the context menu. By specifying
image/*, the option will only show up when image files are selected. You can addvideo/*or other types if needed. - Actions: This lists the internal action names defined below. Here we define one action named
Slideshow. - Exec: This is the command that runs.
%Fis a special placeholder that Dolphin replaces with the full paths of all selected files.feh -F -ris a common command forfeh(Fast Picture Viewer) where-Fforces fullscreen and-renables random order. You can replacefehwitheog(Eye of GNOME) ormpvdepending on your preference. - Terminal=false: This ensures the command runs in the background without opening a terminal window, which is usually desired for media playback.
If you need to pass arguments differently or handle folders, you might use %U instead of %F. %F provides local file paths, while %U provides URLs, which is useful if you want to support remote files later.
Installing the Service Menu
Once you have crafted the XML content, save the file. The next step is to place it in the correct directory so Dolphin recognizes it. Create the directory if it does not exist:
mkdir -p ~/.local/share/kio/servicemenus/
Move your slideshow.desktop file into this directory:
mv slideshow.desktop ~/.local/share/kio/servicemenus/
Ensure the file has the correct permissions. It should be readable by your user:
chmod 644 ~/.local/share/kio/servicemenus/slideshow.desktop
Dolphin caches its service menus. To see the new action immediately, you may need to restart Dolphin. Close all instances of Dolphin and reopen it. Alternatively, you can log out and log back in, but restarting the file manager is usually sufficient.
Testing and Troubleshooting
After restarting Dolphin, navigate to a folder containing images. Select one or more images, then right-click to open the context menu. You should see the "Show Slideshow" option. Clicking it should launch your chosen viewer in slideshow mode.
If the option does not appear, check the following:
- MimeType Mismatch: Ensure the files you selected match the
MimeTypedefined in your XML. If you are selecting PDFs, ensureapplication/pdfis included. - Syntax Errors: Use
desktop-file-validateon your.desktopfile to check for XML or syntax errors. This tool will report any issues preventing the file from being loaded. - Command Availability: Verify that the command specified in
Exec(e.g.,feh) is installed and available in your$PATH. You can test this by running the command manually in a terminal with%Freplaced by actual file paths.
For more complex scripting needs, such as processing files before viewing, consider how shell scripts integrate with system services. Understanding execution contexts is vital when moving between different file managers.
Advanced Customization
You can extend the functionality by adding multiple actions. For example, you might want a "Fullscreen Slideshow" and a "Windowed Preview." Add another section to your XML:
[Desktop Action Windowed]
Name=Windowed Preview
Exec=eog %F
Icon=media-playback-start
Terminal=false
And update the Actions line to include both:
Actions=Slideshow;Windowed;
This flexibility allows you to tailor the user experience precisely. Remember that each action must have a unique name and a distinct Name field for the context menu label.
If you encounter issues with script execution permissions or environment variables, reviewing general shell script execution principles can be helpful. Properly configuring your environment ensures that your custom actions run reliably across different sessions.
Frequently Asked Questions
What if the slideshow option doesn't appear after creating the file?
First, verify that the file is saved with the .desktop extension and placed in ~/.local/share/kio/servicemenus/. Then, restart Dolphin completely or validate the file using desktop-file-validate to check for syntax errors that prevent loading.
Can I use this method for non-image files like videos?
Yes, simply modify the MimeType field in the XML file to include video/* or specific MIME types like video/mp4. This will make the action appear when video files are selected, allowing you to use players like mpv or vlc in the Exec command.
How do I change the order of images in the slideshow?
The order depends on the player used. For feh, use -r for random order or omit it for alphabetical sorting. For mpv, you can use --shuffle for random playback. Adjust the arguments in the Exec line of your .desktop file accordingly.
Is it possible to run a bash script instead of a direct command?
Absolutely. You can specify a path to a bash script in the Exec line, such as Exec=/home/user/scripts/slideshow.sh %F. Ensure the script is executable (chmod +x) and handles the passed file arguments correctly within the script itself.
Why does my action work in Nemo but not in Dolphin?
Nemo and Dolphin use different mechanisms for context menu extensions. Nemo uses INI files in ~/.local/share/nemo/actions/, while Dolphin uses XML-based servicemenus in ~/.local/share/kio/servicemenus/. You must create a separate configuration for Dolphin even if you already have a working Nemo action.