This article explains how to integrate Shotwell delivered as a Flatpak application into the GNOME desktop, to preview image files.
I liked using the Shotwell image view, but it had some bugs, so I went to the Shotwell site looking for the sources. The latest release was newer than the version on my desktop, so I decided to try that first. It was delivered as a Flatpak, and I had to manually integrate it with my desktop by writing a .desktop file.
What is Flatpak?
Flatpak is a way to download and install an application, so all its dependencies are included, and it runs in a secured sandbox. (Flatpak is similar to Ubuntu’s Snaps. They use Linux container features to create the sandbox.)
What is Shotwell Preview?
Shotwell is an application similar to iPhoto on the Mac. There’s no program called Shotwell Preview, but that’s what I’m calling the part of the application that views a file and allows you to edit it, a little bit.
If you open shotwell with a filename, it’ll open the file and allow you to edit it. If you have the regular Shotwell installed on your system, this command opens a file for preview and editing:
However, as noted, the version on my system, 0.28, had some bugs.
So I removed Shotwell, and then installed the latest Shotwell Flatpak.
Suddenly, I could no longer use Shotwell to preview the files in Nautilus, the GNOME desktop file finder.
I needed to create a .desktop file for the preview.
What is a .desktop File?
A .desktop file is an integration point between programs and the Open Desktop environment.
The main place you see them in GNOME is when you click on an icon in the Activities or select an application in the GNOME Shell.
Desktop files are simple text files using the INI file format. This is the file I created to enable Shotwell Preview.
[Desktop Entry] Version=0.30.8 Type=Application Name=Shotwell Preview GenericName=Image Editor Comment=View and edit photographs Exec=flatpak run --filesystem=/mnt/green2tb/johnk/ --filesystem=/home/johnk org.gnome.Shotwell %U Icon=shotwell Terminal=false Categories=Graphics;2DGraphics;RasterGraphics;GTK; StartupNotify=true MimeType=image/bmp;image/g3fax;image/gif;image/tiff;image/jpeg;image/png;
It’s mostly self-explanatory, but we’ll get into the Exec command line later.
Desktop files describe how the command should be run. It includes a reference to an icon file. It lists the MIME types that this application can open – and that’s how the desktop offers you lists of applications to open a file. It has a long name to display in the GNOME Shell.
These .desktop files are kept in .local/share/applications. Any changes in that directory are monitored by GNOME, and immediately affect future uses.
How to Run Flatpak Applications
Flatpak applications are run like this:
flatpak run org.gnome.Shotwell
You can combine that with the Shotwell parameters to open a specific file.
flatpak run org.gnome.Shotwell path/to/file.jpg
That above command won’t allow you to preview files because Flatpak applications are sandboxed, and prevented from accessing your files.
You need to grant the application access to your files by altering the sandbox permissions. You just add options after “run” to allow more access to your command.
In my desktop file’s Exec config, I enabled access to my home directory, and a second directory where I keep bigger files:
Exec=flatpak run --filesystem=/mnt/green2tb/johnk/ --filesystem=/home/johnk org.gnome.Shotwell %U
After I enabled access to files, the preview worked.
- flatpak applications are sandboxed, and you need to enable access to the local system’s resources.
- desktop files integrate application binaries, and Flatpak applications, into your user desktop experience.
- Distros take care of the installation and desktop file integrations, but when you download apps yourself, you will need to perform this integration yourself.
The bad news: the little glitches I experienced weren’t corrected, so I still need to download sources, build the application (and the flatpak), and write up a bug report and fixes. It’s going to take a while because I don’t know Vala.